1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 2 // This source code is licensed under both the GPLv2 (found in the 3 // COPYING file in the root directory) and Apache 2.0 License 4 // (found in the LICENSE.Apache file in the root directory). 5 // 6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 // Use of this source code is governed by a BSD-style license that can be 8 // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 10 #pragma once 11 #include "rocksdb/iterator.h" 12 #include "rocksdb/env.h" 13 #include "table/iterator_wrapper.h" 14 15 namespace ROCKSDB_NAMESPACE { 16 17 struct ReadOptions; 18 class InternalKeyComparator; 19 20 // TwoLevelIteratorState expects iterators are not created using the arena 21 struct TwoLevelIteratorState { TwoLevelIteratorStateTwoLevelIteratorState22 TwoLevelIteratorState() {} 23 ~TwoLevelIteratorStateTwoLevelIteratorState24 virtual ~TwoLevelIteratorState() {} 25 virtual InternalIteratorBase<IndexValue>* NewSecondaryIterator( 26 const BlockHandle& handle) = 0; 27 }; 28 29 // Return a new two level iterator. A two-level iterator contains an 30 // index iterator whose values point to a sequence of blocks where 31 // each block is itself a sequence of key,value pairs. The returned 32 // two-level iterator yields the concatenation of all key/value pairs 33 // in the sequence of blocks. Takes ownership of "index_iter" and 34 // will delete it when no longer needed. 35 // 36 // Uses a supplied function to convert an index_iter value into 37 // an iterator over the contents of the corresponding block. 38 // Note: this function expects first_level_iter was not created using the arena 39 extern InternalIteratorBase<IndexValue>* NewTwoLevelIterator( 40 TwoLevelIteratorState* state, 41 InternalIteratorBase<IndexValue>* first_level_iter); 42 43 } // namespace ROCKSDB_NAMESPACE 44