// Copyright (c) 2011-present, 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.
+// This source code is licensed under both the GPLv2 (found in the
+// COPYING file in the root directory) and Apache 2.0 License
+// (found in the LICENSE.Apache file in the root directory).
#pragma once
#ifndef ROCKSDB_LITE
#include <vector>
#include <queue>
+#include "db/dbformat.h"
+#include "memory/arena.h"
#include "rocksdb/db.h"
#include "rocksdb/iterator.h"
#include "rocksdb/options.h"
-#include "db/dbformat.h"
#include "table/internal_iterator.h"
-#include "util/arena.h"
-namespace rocksdb {
+namespace ROCKSDB_NAMESPACE {
class DBImpl;
class Env;
struct SuperVersion;
class ColumnFamilyData;
-class LevelIterator;
+class ForwardLevelIterator;
class VersionStorageInfo;
struct FileMetaData;
class ForwardIterator : public InternalIterator {
public:
ForwardIterator(DBImpl* db, const ReadOptions& read_options,
- ColumnFamilyData* cfd, SuperVersion* current_sv = nullptr);
+ ColumnFamilyData* cfd, SuperVersion* current_sv = nullptr,
+ bool allow_unprepared_value = false);
virtual ~ForwardIterator();
- void SeekForPrev(const Slice& target) override {
+ void SeekForPrev(const Slice& /*target*/) override {
status_ = Status::NotSupported("ForwardIterator::SeekForPrev()");
valid_ = false;
}
virtual Slice key() const override;
virtual Slice value() const override;
virtual Status status() const override;
+ virtual bool PrepareValue() override;
virtual Status GetProperty(std::string prop_name, std::string* prop) override;
virtual void SetPinnedItersMgr(
PinnedIteratorsManager* pinned_iters_mgr) override;
private:
void Cleanup(bool release_sv);
+ // Unreference and, if needed, clean up the current SuperVersion. This is
+ // either done immediately or deferred until this iterator is unpinned by
+ // PinnedIteratorsManager.
void SVCleanup();
+ static void SVCleanup(
+ DBImpl* db, SuperVersion* sv, bool background_purge_on_iterator_cleanup);
+ static void DeferredSVCleanup(void* arg);
+
void RebuildIterators(bool refresh_sv);
void RenewIterators();
void BuildLevelIterators(const VersionStorageInfo* vstorage);
ColumnFamilyData* const cfd_;
const SliceTransform* const prefix_extractor_;
const Comparator* user_comparator_;
+ const bool allow_unprepared_value_;
MinIterHeap immutable_min_heap_;
SuperVersion* sv_;
InternalIterator* mutable_iter_;
std::vector<InternalIterator*> imm_iters_;
std::vector<InternalIterator*> l0_iters_;
- std::vector<LevelIterator*> level_iters_;
+ std::vector<ForwardLevelIterator*> level_iters_;
InternalIterator* current_;
bool valid_;
Arena arena_;
};
-} // namespace rocksdb
+} // namespace ROCKSDB_NAMESPACE
#endif // ROCKSDB_LITE