/src/rocksdb/table/iterator.cc
Line | Count | Source (jump to first uncovered line) |
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 | | |
10 | | #include "rocksdb/iterator.h" |
11 | | |
12 | | #include "memory/arena.h" |
13 | | #include "table/internal_iterator.h" |
14 | | #include "table/iterator_wrapper.h" |
15 | | |
16 | | namespace ROCKSDB_NAMESPACE { |
17 | | |
18 | 0 | Status Iterator::GetProperty(std::string prop_name, std::string* prop) { |
19 | 0 | if (prop == nullptr) { |
20 | 0 | return Status::InvalidArgument("prop is nullptr"); |
21 | 0 | } |
22 | 0 | if (prop_name == "rocksdb.iterator.is-key-pinned") { |
23 | 0 | *prop = "0"; |
24 | 0 | return Status::OK(); |
25 | 0 | } |
26 | 0 | if (prop_name == "rocksdb.iterator.is-value-pinned") { |
27 | 0 | *prop = "0"; |
28 | 0 | return Status::OK(); |
29 | 0 | } |
30 | 0 | return Status::InvalidArgument("Unidentified property."); |
31 | 0 | } |
32 | | |
33 | | namespace { |
34 | | class EmptyIterator : public Iterator { |
35 | | public: |
36 | 0 | explicit EmptyIterator(const Status& s) : status_(s) {} |
37 | 0 | bool Valid() const override { return false; } |
38 | 0 | void Seek(const Slice& /*target*/) override {} |
39 | 0 | void SeekForPrev(const Slice& /*target*/) override {} |
40 | 0 | void SeekToFirst() override {} |
41 | 0 | void SeekToLast() override {} |
42 | 0 | void Next() override { assert(false); } |
43 | 0 | void Prev() override { assert(false); } |
44 | 0 | Slice key() const override { |
45 | 0 | assert(false); |
46 | 0 | return Slice(); |
47 | 0 | } |
48 | 0 | Slice value() const override { |
49 | 0 | assert(false); |
50 | 0 | return Slice(); |
51 | 0 | } |
52 | 0 | Status status() const override { return status_; } |
53 | | |
54 | | private: |
55 | | Status status_; |
56 | | }; |
57 | | |
58 | | template <class TValue = Slice> |
59 | | class EmptyInternalIterator : public InternalIteratorBase<TValue> { |
60 | | public: |
61 | 0 | explicit EmptyInternalIterator(const Status& s) : status_(s) {} Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::EmptyInternalIterator(rocksdb::Status const&) Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::EmptyInternalIterator(rocksdb::Status const&) |
62 | 0 | bool Valid() const override { return false; } Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::Valid() const Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::Valid() const |
63 | 0 | void Seek(const Slice& /*target*/) override {} Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::Seek(rocksdb::Slice const&) Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::Seek(rocksdb::Slice const&) |
64 | 0 | void SeekForPrev(const Slice& /*target*/) override {} Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::SeekForPrev(rocksdb::Slice const&) Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::SeekForPrev(rocksdb::Slice const&) |
65 | 0 | void SeekToFirst() override {} Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::SeekToFirst() Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::SeekToFirst() |
66 | 0 | void SeekToLast() override {} Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::SeekToLast() Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::SeekToLast() |
67 | 0 | void Next() override { assert(false); } Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::Next() Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::Next() |
68 | 0 | void Prev() override { assert(false); } Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::Prev() Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::Prev() |
69 | 0 | Slice key() const override { |
70 | 0 | assert(false); |
71 | 0 | return Slice(); |
72 | 0 | } Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::key() const Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::key() const |
73 | 0 | TValue value() const override { |
74 | 0 | assert(false); |
75 | 0 | return TValue(); |
76 | 0 | } Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::value() const Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::value() const |
77 | 0 | Status status() const override { return status_; } Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::IndexValue>::status() const Unexecuted instantiation: iterator.cc:rocksdb::(anonymous namespace)::EmptyInternalIterator<rocksdb::Slice>::status() const |
78 | | |
79 | | private: |
80 | | Status status_; |
81 | | }; |
82 | | } // namespace |
83 | | |
84 | 0 | Iterator* NewEmptyIterator() { return new EmptyIterator(Status::OK()); } |
85 | | |
86 | 0 | Iterator* NewErrorIterator(const Status& status) { |
87 | 0 | return new EmptyIterator(status); |
88 | 0 | } |
89 | | |
90 | | template <class TValue> |
91 | 0 | InternalIteratorBase<TValue>* NewErrorInternalIterator(const Status& status) { |
92 | 0 | return new EmptyInternalIterator<TValue>(status); |
93 | 0 | } Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::IndexValue>* rocksdb::NewErrorInternalIterator<rocksdb::IndexValue>(rocksdb::Status const&) Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::Slice>* rocksdb::NewErrorInternalIterator<rocksdb::Slice>(rocksdb::Status const&) |
94 | | template InternalIteratorBase<IndexValue>* NewErrorInternalIterator( |
95 | | const Status& status); |
96 | | template InternalIteratorBase<Slice>* NewErrorInternalIterator( |
97 | | const Status& status); |
98 | | |
99 | | template <class TValue> |
100 | | InternalIteratorBase<TValue>* NewErrorInternalIterator(const Status& status, |
101 | 0 | Arena* arena) { |
102 | 0 | if (arena == nullptr) { |
103 | 0 | return NewErrorInternalIterator<TValue>(status); |
104 | 0 | } else { |
105 | 0 | auto mem = arena->AllocateAligned(sizeof(EmptyInternalIterator<TValue>)); |
106 | 0 | return new (mem) EmptyInternalIterator<TValue>(status); |
107 | 0 | } |
108 | 0 | } Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::IndexValue>* rocksdb::NewErrorInternalIterator<rocksdb::IndexValue>(rocksdb::Status const&, rocksdb::Arena*) Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::Slice>* rocksdb::NewErrorInternalIterator<rocksdb::Slice>(rocksdb::Status const&, rocksdb::Arena*) |
109 | | template InternalIteratorBase<IndexValue>* NewErrorInternalIterator( |
110 | | const Status& status, Arena* arena); |
111 | | template InternalIteratorBase<Slice>* NewErrorInternalIterator( |
112 | | const Status& status, Arena* arena); |
113 | | |
114 | | template <class TValue> |
115 | 0 | InternalIteratorBase<TValue>* NewEmptyInternalIterator() { |
116 | 0 | return new EmptyInternalIterator<TValue>(Status::OK()); |
117 | 0 | } Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::IndexValue>* rocksdb::NewEmptyInternalIterator<rocksdb::IndexValue>() Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::Slice>* rocksdb::NewEmptyInternalIterator<rocksdb::Slice>() |
118 | | template InternalIteratorBase<IndexValue>* NewEmptyInternalIterator(); |
119 | | template InternalIteratorBase<Slice>* NewEmptyInternalIterator(); |
120 | | |
121 | | template <class TValue> |
122 | 0 | InternalIteratorBase<TValue>* NewEmptyInternalIterator(Arena* arena) { |
123 | 0 | if (arena == nullptr) { |
124 | 0 | return NewEmptyInternalIterator<TValue>(); |
125 | 0 | } else { |
126 | 0 | auto mem = arena->AllocateAligned(sizeof(EmptyInternalIterator<TValue>)); |
127 | 0 | return new (mem) EmptyInternalIterator<TValue>(Status::OK()); |
128 | 0 | } |
129 | 0 | } Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::IndexValue>* rocksdb::NewEmptyInternalIterator<rocksdb::IndexValue>(rocksdb::Arena*) Unexecuted instantiation: rocksdb::InternalIteratorBase<rocksdb::Slice>* rocksdb::NewEmptyInternalIterator<rocksdb::Slice>(rocksdb::Arena*) |
130 | | template InternalIteratorBase<IndexValue>* NewEmptyInternalIterator( |
131 | | Arena* arena); |
132 | | template InternalIteratorBase<Slice>* NewEmptyInternalIterator(Arena* arena); |
133 | | |
134 | | } // namespace ROCKSDB_NAMESPACE |