7d817268b9
Summary: This is a diff for managed iterator. A managed iterator is a wrapper around an iterator which saves the options for that iterator as well as the current key/value so that the underlying iterator and its associated memory can be released when it is aged out automatically or on the request of the user. Will provide the automatic release as a follow-up diff. Test Plan: Managed* tests in db_test and XF tests for managed iterator Reviewers: igor, yhchiang, anthony, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D31401
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under the BSD-style license found in the
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
#include <string>
|
|
#include "db/db_impl.h"
|
|
#include "db/managed_iterator.h"
|
|
#include "rocksdb/options.h"
|
|
#include "util/xfunc.h"
|
|
|
|
#ifdef XFUNC
|
|
|
|
namespace rocksdb {
|
|
|
|
std::string XFuncPoint::xfunc_test_;
|
|
bool XFuncPoint::initialized_ = false;
|
|
bool XFuncPoint::enabled_ = false;
|
|
int XFuncPoint::skip_policy_ = 0;
|
|
|
|
void GetXFTestOptions(Options* options, int skip_policy) {
|
|
if (XFuncPoint::Check("inplace_lock_test") &&
|
|
(!(skip_policy & kSkipNoSnapshot))) {
|
|
options->inplace_update_support = true;
|
|
}
|
|
}
|
|
|
|
void xf_manage_release(ManagedIterator* iter) {
|
|
if (!(XFuncPoint::GetSkip() & kSkipNoPrefix)) {
|
|
iter->ReleaseIter(false);
|
|
}
|
|
}
|
|
|
|
void xf_manage_options(ReadOptions* read_options) {
|
|
if (!XFuncPoint::Check("managed_xftest_dropold") &&
|
|
(!XFuncPoint::Check("managed_xftest_release"))) {
|
|
return;
|
|
}
|
|
read_options->managed = true;
|
|
}
|
|
|
|
void xf_manage_new(DBImpl* db, ReadOptions* read_options,
|
|
bool is_snapshot_supported) {
|
|
if ((!XFuncPoint::Check("managed_xftest_dropold") &&
|
|
(!XFuncPoint::Check("managed_xftest_release"))) ||
|
|
(!read_options->managed)) {
|
|
return;
|
|
}
|
|
if ((!read_options->tailing) && (read_options->snapshot == nullptr) &&
|
|
(!is_snapshot_supported)) {
|
|
read_options->managed = false;
|
|
return;
|
|
}
|
|
if (db->GetOptions().prefix_extractor != nullptr) {
|
|
if (strcmp(db->GetOptions().table_factory.get()->Name(), "PlainTable")) {
|
|
if (!(XFuncPoint::GetSkip() & kSkipNoPrefix)) {
|
|
read_options->total_order_seek = true;
|
|
}
|
|
} else {
|
|
read_options->managed = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
void xf_manage_create(ManagedIterator* iter) { iter->SetDropOld(false); }
|
|
|
|
} // namespace rocksdb
|
|
|
|
#endif // XFUNC
|