Row Sequences¶
Description¶
A
RowSequence
is an abstract class representing a monotonically-increasing sequence of row numbers that can be
used to reference elements in a
ClientTable
or
ColumnSource
.
It is used as a parameter to methods like
Stream
and
fillChunk
.
The row numbers inside a
RowSequence
are uint64_t
values. The coordinate space used (whether key space or position space)
is not specified, and is implied by context. However, as of this writing, all of the public
methods in the C++ client that take
RowSequence
arguments
assume they are in position space.
RowSequence
objects are immutable. They can be sliced via the
Take
and
Drop
methods, which return new
RowSequence
shared_ptrs.
You can interrogate their size via
size
or
empty
.
You can iterate over them with
forEachInterval
or by obtaining a
RowSequenceIterator
via
getRowSequenceIterator
Declarations¶
-
class RowSequence¶
Represets a monotonically increasing sequence of row numbers. The coordinate space of those row numbers (key space vs index space) is unspecified here.
Public Functions
-
virtual ~RowSequence()¶
Destructor.
-
RowSequenceIterator GetRowSequenceIterator() const¶
Create a RowSequenceIterator.
-
virtual std::shared_ptr<RowSequence> Take(size_t size) const = 0¶
Return a RowSequence consisting of the first ‘Size’ elements of this RowSequence. If Size >= this->Size(), the method may return this RowSequence.
-
virtual std::shared_ptr<RowSequence> Drop(size_t size) const = 0¶
Return a RowSequence consisting of the remaining elements of this RowSequence after dropping ‘size’ elements. If Size >= this->Size(), returns the empty RowSequence.
-
virtual void ForEachInterval(const std::function<void(uint64_t begin_key, uint64_t end_key)> &callback) const = 0¶
Iterates over the RowSequence and invokes the callback on each of the contiguous intervals that it contains. The intervals passed to the callback will be represented as half-open intervals [begin, end).
-
virtual size_t Size() const = 0¶
The number of elements in this RowSequence.
Public Static Functions
-
static std::shared_ptr<RowSequence> CreateEmpty()¶
Create an empty RowSequence.
-
static std::shared_ptr<RowSequence> CreateSequential(uint64_t begin, uint64_t end)¶
Create a dense RowSequence providing values from the half open interval [begin, end).
Friends
-
friend std::ostream &operator<<(std::ostream &s, const RowSequence &o)¶
Print this RowSequence to a std::ostream.
-
virtual ~RowSequence()¶
-
class RowSequenceBuilder¶
Builder class for RowSequence.
Public Functions
-
RowSequenceBuilder()¶
Constructor.
-
~RowSequenceBuilder()¶
Destructor.
-
void AddInterval(uint64_t begin, uint64_t end)¶
Adds the half-open interval [begin, end) to the RowSequence. The added interval need not be disjoint.
-
inline void Add(uint64_t key)¶
Adds ‘key’ to the RowSequence. If the key is already present, does nothing.
-
std::shared_ptr<RowSequence> Build()¶
Builds the RowSequence.
-
RowSequenceBuilder()¶
-
class RowSequenceIterator¶
An iterator for RowSequence objects. This is not a standard C++ style iterator but rather a more heavyweight object that supports forward iteration one step at a time.
Public Functions
Constructor. Used internally.
-
RowSequenceIterator(RowSequenceIterator &&other) noexcept¶
Move constructor.
-
~RowSequenceIterator()¶
Destructor.
-
bool TryGetNext(uint64_t *result)¶
Get the next value in the iteration.
- Parameters:
result – A pointer to caller-managed storage to store the next value.
- Returns:
True if the next value was stored in *result. False if there are no more values.