YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rocksdb/table/two_level_iterator.h
Line
Count
Source
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under the BSD-style license found in the
3
//  LICENSE file in the root directory of this source tree. An additional grant
4
//  of patent rights can be found in the PATENTS file in the same directory.
5
//
6
// The following only applies to changes made to this file as part of YugaByte development.
7
//
8
// Portions Copyright (c) YugaByte, Inc.
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
11
// in compliance with the License.  You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software distributed under the License
16
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17
// or implied.  See the License for the specific language governing permissions and limitations
18
// under the License.
19
//
20
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
21
// Use of this source code is governed by a BSD-style license that can be
22
// found in the LICENSE file. See the AUTHORS file for names of contributors.
23
24
#pragma once
25
26
#include "yb/rocksdb/iterator.h"
27
#include "yb/rocksdb/table/internal_iterator.h"
28
29
namespace rocksdb {
30
31
struct ReadOptions;
32
class InternalKeyComparator;
33
class Arena;
34
35
struct TwoLevelIteratorState {
36
  explicit TwoLevelIteratorState(bool _check_prefix_may_match)
37
3.87M
      : check_prefix_may_match(_check_prefix_may_match) {}
38
39
3.86M
  virtual ~TwoLevelIteratorState() {}
40
  virtual InternalIterator* NewSecondaryIterator(const Slice& handle) = 0;
41
  virtual bool PrefixMayMatch(const Slice& internal_key) = 0;
42
43
  // If call PrefixMayMatch()
44
  bool check_prefix_may_match;
45
};
46
47
48
// Return a new two level iterator.  A two-level iterator contains an
49
// index iterator whose values point to a sequence of blocks where
50
// each block is itself a sequence of key,value pairs.  The returned
51
// two-level iterator yields the concatenation of all key/value pairs
52
// in the sequence of blocks.  Takes ownership of "index_iter" and
53
// will delete it when no longer needed.
54
//
55
// Uses a supplied function to convert an index_iter value into
56
// an iterator over the contents of the corresponding block.
57
// arena: If not null, the arena is used to allocate the Iterator.
58
//        When destroying the iterator, the destructor will destroy
59
//        all the states but those allocated in arena.
60
// need_free_iter_and_state: free `state` and `first_level_iter` if
61
//                           true. Otherwise, just call destructor.
62
extern InternalIterator* NewTwoLevelIterator(
63
    TwoLevelIteratorState* state, InternalIterator* first_level_iter, Arena* arena = nullptr,
64
    bool need_free_iter_and_state = true);
65
66
}  // namespace rocksdb