16 typedef Iterator* (*BlockFunction)(
void*,
const ReadOptions&,
const Slice&);
18 class TwoLevelIterator:
public Iterator {
22 BlockFunction block_function,
24 const ReadOptions& options);
26 virtual ~TwoLevelIterator();
28 virtual void Seek(
const Slice& target);
29 virtual void SeekToFirst();
30 virtual void SeekToLast();
34 virtual bool Valid()
const {
37 virtual Slice key()
const {
41 virtual Slice
value()
const {
45 virtual Status status()
const {
57 void SaveError(
const Status& s) {
60 void SkipEmptyDataBlocksForward();
61 void SkipEmptyDataBlocksBackward();
62 void SetDataIterator(Iterator* data_iter);
76 TwoLevelIterator::TwoLevelIterator(
78 BlockFunction block_function,
80 const ReadOptions& options)
88 TwoLevelIterator::~TwoLevelIterator() {
91 void TwoLevelIterator::Seek(
const Slice& target) {
95 SkipEmptyDataBlocksForward();
98 void TwoLevelIterator::SeekToFirst() {
102 SkipEmptyDataBlocksForward();
105 void TwoLevelIterator::SeekToLast() {
109 SkipEmptyDataBlocksBackward();
112 void TwoLevelIterator::Next() {
115 SkipEmptyDataBlocksForward();
118 void TwoLevelIterator::Prev() {
121 SkipEmptyDataBlocksBackward();
125 void TwoLevelIterator::SkipEmptyDataBlocksForward() {
129 SetDataIterator(NULL);
138 void TwoLevelIterator::SkipEmptyDataBlocksBackward() {
142 SetDataIterator(NULL);
151 void TwoLevelIterator::SetDataIterator(Iterator* data_iter) {
156 void TwoLevelIterator::InitDataBlock() {
158 SetDataIterator(NULL);
165 Iterator* iter = (*block_function_)(
arg_,
options_, handle);
167 SetDataIterator(iter);
176 BlockFunction block_function,
178 const ReadOptions& options) {
179 return new TwoLevelIterator(index_iter, block_function, arg, options);
std::string data_block_handle_
IteratorWrapper data_iter_
BlockFunction block_function_
IteratorWrapper index_iter_
const ReadOptions options_
Iterator * NewTwoLevelIterator(Iterator *index_iter, BlockFunction block_function, void *arg, const ReadOptions &options)