two_level_iterator.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #pragma once
  10. #include "rocksdb/iterator.h"
  11. #include "rocksdb/env.h"
  12. #include "table/iterator_wrapper.h"
  13. namespace ROCKSDB_NAMESPACE {
  14. struct ReadOptions;
  15. class InternalKeyComparator;
  16. // TwoLevelIteratorState expects iterators are not created using the arena
  17. struct TwoLevelIteratorState {
  18. TwoLevelIteratorState() {}
  19. virtual ~TwoLevelIteratorState() {}
  20. virtual InternalIteratorBase<IndexValue>* NewSecondaryIterator(
  21. const BlockHandle& handle) = 0;
  22. };
  23. // Return a new two level iterator. A two-level iterator contains an
  24. // index iterator whose values point to a sequence of blocks where
  25. // each block is itself a sequence of key,value pairs. The returned
  26. // two-level iterator yields the concatenation of all key/value pairs
  27. // in the sequence of blocks. Takes ownership of "index_iter" and
  28. // will delete it when no longer needed.
  29. //
  30. // Uses a supplied function to convert an index_iter value into
  31. // an iterator over the contents of the corresponding block.
  32. // Note: this function expects first_level_iter was not created using the arena
  33. extern InternalIteratorBase<IndexValue>* NewTwoLevelIterator(
  34. TwoLevelIteratorState* state,
  35. InternalIteratorBase<IndexValue>* first_level_iter);
  36. } // namespace ROCKSDB_NAMESPACE