/Users/deen/code/yugabyte-db/src/yb/docdb/bounded_rocksdb_iterator.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_DOCDB_BOUNDED_ROCKSDB_ITERATOR_H_ |
15 | | #define YB_DOCDB_BOUNDED_ROCKSDB_ITERATOR_H_ |
16 | | |
17 | | #include <stdint.h> |
18 | | |
19 | | #include <string> |
20 | | #include <vector> |
21 | | |
22 | | #include "yb/docdb/docdb_fwd.h" |
23 | | |
24 | | #include "yb/rocksdb/iterator.h" |
25 | | #include "yb/rocksdb/options.h" |
26 | | |
27 | | namespace yb { |
28 | | namespace docdb { |
29 | | |
30 | | class BoundedRocksDbIterator : public rocksdb::Iterator { |
31 | | public: |
32 | 17.7M | BoundedRocksDbIterator() = default; |
33 | | |
34 | | BoundedRocksDbIterator( |
35 | | rocksdb::DB* rocksdb, const rocksdb::ReadOptions& read_opts, const KeyBounds* key_bounds); |
36 | | |
37 | | BoundedRocksDbIterator(const BoundedRocksDbIterator& other) = delete; |
38 | | void operator=(const BoundedRocksDbIterator& other) = delete; |
39 | | |
40 | | BoundedRocksDbIterator(BoundedRocksDbIterator&&) = default; |
41 | 12.9M | BoundedRocksDbIterator& operator=(BoundedRocksDbIterator&&) = default; |
42 | | |
43 | 780M | bool Initialized() const { return iterator_ != nullptr; } |
44 | | |
45 | | bool Valid() const override; |
46 | | |
47 | | void SeekToFirst() override; |
48 | | |
49 | | void SeekToLast() override; |
50 | | |
51 | | void Seek(const Slice& target) override; |
52 | | |
53 | | void Next() override; |
54 | | |
55 | | void Prev() override; |
56 | | |
57 | | Slice key() const override; |
58 | | |
59 | | Slice value() const override; |
60 | | |
61 | | Status status() const override; |
62 | | |
63 | 0 | Status GetProperty(std::string prop_name, std::string* prop) override { |
64 | 0 | return iterator_->GetProperty(prop_name, prop); |
65 | 0 | } |
66 | | |
67 | 0 | void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2) { |
68 | 0 | iterator_->RegisterCleanup(function, arg1, arg2); |
69 | 0 | } |
70 | | |
71 | 50.7M | void RevalidateAfterUpperBoundChange() override { |
72 | 50.7M | iterator_->RevalidateAfterUpperBoundChange(); |
73 | 50.7M | } |
74 | | |
75 | 631k | void Reset() { |
76 | 631k | iterator_.reset(); |
77 | 631k | } |
78 | | |
79 | | private: |
80 | | std::unique_ptr<rocksdb::Iterator> iterator_; |
81 | | const KeyBounds* key_bounds_; |
82 | | }; |
83 | | |
84 | | } // namespace docdb |
85 | | } // namespace yb |
86 | | |
87 | | #endif // YB_DOCDB_BOUNDED_ROCKSDB_ITERATOR_H_ |