YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rocksdb/table/merger.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
27
28
namespace rocksdb {
29
30
class Comparator;
31
class InternalIterator;
32
class Env;
33
class Arena;
34
35
// Return an iterator that provided the union of the data in
36
// children[0,n-1].  Takes ownership of the child iterators and
37
// will delete them when the result iterator is deleted.
38
//
39
// The result does no duplicate suppression.  I.e., if a particular
40
// key is present in K child iterators, it will be yielded K times.
41
//
42
// REQUIRES: n >= 0
43
extern InternalIterator* NewMergingIterator(const Comparator* comparator,
44
                                            InternalIterator** children, int n,
45
                                            Arena* arena = nullptr);
46
47
class MergingIterator;
48
49
// A builder class to build a merging iterator by adding iterators one by one.
50
class MergeIteratorBuilder {
51
 public:
52
  // comparator: the comparator used in merging comparator
53
  // arena: where the merging iterator needs to be allocated from.
54
  explicit MergeIteratorBuilder(const Comparator* comparator, Arena* arena);
55
15.3M
  ~MergeIteratorBuilder() {}
56
57
  // Add iter to the merging iterator.
58
  void AddIterator(InternalIterator* iter);
59
60
  // Get arena used to build the merging iterator. It is called one a child
61
  // iterator needs to be allocated.
62
3.31M
  Arena* GetArena() { return arena; }
63
64
  // Return the result merging iterator.
65
  InternalIterator* Finish();
66
67
 private:
68
  MergingIterator* merge_iter;
69
  InternalIterator* first_iter;
70
  bool use_merging_iter;
71
  Arena* arena;
72
};
73
74
}  // namespace rocksdb