YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/rocksdb/table/internal_iterator.h
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 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
#ifndef ROCKSDB_TABLE_INTERNAL_ITERATOR_H
21
#define ROCKSDB_TABLE_INTERNAL_ITERATOR_H
22
23
#pragma once
24
25
#include <string>
26
#include "yb/rocksdb/iterator.h"
27
#include "yb/rocksdb/status.h"
28
29
namespace rocksdb {
30
31
class InternalIterator : public Cleanable {
32
 public:
33
197M
  InternalIterator() {}
34
168M
  virtual ~InternalIterator() {}
35
36
  // An iterator is either positioned at a key/value pair, or
37
  // not valid.  This method returns true iff the iterator is valid.
38
  virtual bool Valid() const = 0;
39
40
  // Position at the first key in the source.  The iterator is Valid()
41
  // after this call iff the source is not empty.
42
  virtual void SeekToFirst() = 0;
43
44
  // Position at the last key in the source.  The iterator is
45
  // Valid() after this call iff the source is not empty.
46
  virtual void SeekToLast() = 0;
47
48
  // Position at the first key in the source that at or past target
49
  // The iterator is Valid() after this call iff the source contains
50
  // an entry that comes at or past target.
51
  // target is encoded representation of InternalKey.
52
  virtual void Seek(const Slice& target) = 0;
53
54
  // Moves to the next entry in the source.  After this call, Valid() is
55
  // true iff the iterator was not positioned at the last entry in the source.
56
  // REQUIRES: Valid()
57
  virtual void Next() = 0;
58
59
  // Moves to the previous entry in the source.  After this call, Valid() is
60
  // true iff the iterator was not positioned at the first entry in source.
61
  // REQUIRES: Valid()
62
  virtual void Prev() = 0;
63
64
  // Return the key for the current entry.  The underlying storage for
65
  // the returned slice is valid only until the next modification of
66
  // the iterator.
67
  // REQUIRES: Valid()
68
  virtual Slice key() const = 0;
69
70
  // Return the value for the current entry.  The underlying storage for
71
  // the returned slice is valid only until the next modification of
72
  // the iterator.
73
  // REQUIRES: !AtEnd() && !AtStart()
74
  virtual Slice value() const = 0;
75
76
  // If an error has occurred, return it.  Else return an ok status.
77
  // If non-blocking IO is requested and this operation cannot be
78
  // satisfied without doing some IO, then this returns STATUS(Incomplete, ).
79
  virtual Status status() const = 0;
80
81
  // Make sure that all current and future data blocks used by this iterator
82
  // will be pinned in memory and will not be released except when
83
  // ReleasePinnedData() is called or the iterator is deleted.
84
0
  virtual Status PinData() { return STATUS(NotSupported, ""); }
Unexecuted instantiation: rocksdb::InternalIterator::PinData()
Unexecuted instantiation: rocksdb::InternalIterator::PinData()
85
86
  // Release all blocks that were pinned because of PinData() and no future
87
  // blocks will be pinned.
88
0
  virtual Status ReleasePinnedData() { return STATUS(NotSupported, ""); }
Unexecuted instantiation: rocksdb::InternalIterator::ReleasePinnedData()
Unexecuted instantiation: rocksdb::InternalIterator::ReleasePinnedData()
89
90
  // If true, this means that the Slice returned by key() is valid as long
91
  // as the iterator is not deleted and ReleasePinnedData() is not called.
92
  //
93
  // IsKeyPinned() is guaranteed to always return true if
94
  //  - PinData() is called
95
  //  - DB tables were created with BlockBasedTableOptions::use_delta_encoding
96
  //    set to false.
97
56.8k
  virtual bool IsKeyPinned() const { return false; }
98
99
4
  virtual Status GetProperty(std::string prop_name, std::string* prop) {
100
4
    return STATUS(NotSupported, "");
101
4
  }
102
103
 private:
104
  // No copying allowed
105
  InternalIterator(const InternalIterator&) = delete;
106
  InternalIterator& operator=(const InternalIterator&) = delete;
107
};
108
109
// Return an empty iterator (yields nothing).
110
extern InternalIterator* NewEmptyInternalIterator();
111
112
// Return an empty iterator with the specified status.
113
extern InternalIterator* NewErrorInternalIterator(const Status& status);
114
115
}  // namespace rocksdb
116
117
#endif // ROCKSDB_TABLE_INTERNAL_ITERATOR_H