/Users/deen/code/yugabyte-db/src/yb/rocksdb/table/iter_heap.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 | | |
21 | | #pragma once |
22 | | |
23 | | #include "yb/rocksdb/comparator.h" |
24 | | #include "yb/rocksdb/table/iterator_wrapper.h" |
25 | | |
26 | | namespace rocksdb { |
27 | | |
28 | | // When used with std::priority_queue, this comparison functor puts the |
29 | | // iterator with the max/largest key on top. |
30 | | class MaxIteratorComparator { |
31 | | public: |
32 | | MaxIteratorComparator(const Comparator* comparator) : |
33 | 4.34k | comparator_(comparator) {} |
34 | | |
35 | 18.0M | bool operator()(IteratorWrapper* a, IteratorWrapper* b) const { |
36 | 18.0M | return comparator_->Compare(a->key(), b->key()) < 0; |
37 | 18.0M | } |
38 | | private: |
39 | | const Comparator* comparator_; |
40 | | }; |
41 | | |
42 | | // When used with std::priority_queue, this comparison functor puts the |
43 | | // iterator with the min/smallest key on top. |
44 | | class MinIteratorComparator { |
45 | | public: |
46 | | MinIteratorComparator(const Comparator* comparator) : |
47 | 15.4M | comparator_(comparator) {} |
48 | | |
49 | 521M | bool operator()(IteratorWrapper* a, IteratorWrapper* b) const { |
50 | 521M | return comparator_->Compare(a->key(), b->key()) > 0; |
51 | 521M | } |
52 | | private: |
53 | | const Comparator* comparator_; |
54 | | }; |
55 | | |
56 | | } // namespace rocksdb |