libfoedus-core
FOEDUS Core Library
|
A cursor interface to read tuples from a sequential storage. More...
A cursor interface to read tuples from a sequential storage.
Unlike other storages, the only read-access to sequential storages is, as the name implies, a full sequential scan. This cursor interface is thus optimized for cases where we scan millions of records. This implies that, unlike masstree's cursor, we don't have to worry about infrequent overheads, such as new/delete in initialization.
Definition at line 91 of file sequential_cursor.hpp.
#include <sequential_cursor.hpp>
Public Types | |
enum | OrderMode { kNodeFirstMode, kLooseEpochSortMode } |
The order this cursor returns tuples. More... | |
Public Member Functions | |
SequentialCursor (thread::Thread *context, const sequential::SequentialStorage &storage, void *buffer, uint64_t buffer_size, OrderMode order_mode=kNodeFirstMode, Epoch from_epoch=INVALID_EPOCH, Epoch to_epoch=INVALID_EPOCH, int32_t node_filter=-1) | |
Constructs a cursor to read tuples from this storage. More... | |
~SequentialCursor () | |
thread::Thread * | get_context () const |
const sequential::SequentialStorage & | get_storage () const |
Epoch | get_from_epoch () const |
Epoch | get_to_epoch () const |
ErrorCode | next_batch (SequentialRecordIterator *out) |
Returns a batch of records as an iterator. More... | |
bool | is_valid () const |
bool | is_finished_snapshots () const |
Followings are rather implementation details. Used only from testcases. More... | |
bool | is_finished_safe_volatiles () const |
bool | is_finished_unsafe_volatiles () const |
Friends | |
std::ostream & | operator<< (std::ostream &o, const SequentialCursor &v) |
The order this cursor returns tuples.
Definition at line 94 of file sequential_cursor.hpp.
foedus::storage::sequential::SequentialCursor::SequentialCursor | ( | thread::Thread * | context, |
const sequential::SequentialStorage & | storage, | ||
void * | buffer, | ||
uint64_t | buffer_size, | ||
OrderMode | order_mode = kNodeFirstMode , |
||
Epoch | from_epoch = INVALID_EPOCH , |
||
Epoch | to_epoch = INVALID_EPOCH , |
||
int32_t | node_filter = -1 |
||
) |
Constructs a cursor to read tuples from this storage.
[in] | context | Thread context of the transaction |
[in] | storage | The sequential storage to read from |
[in,out] | buffer | The buffer to read a number of snapshot pages in a batch. This buffer must be aligned for direct-IO. |
[in] | buffer_size | Byte size of buffer. Must be at least 4kb. |
[in] | order_mode | The order this cursor returns tuples |
[in] | from_epoch | Inclusive beginning of epochs to read. If not specified, all epochs. |
[in] | to_epoch | Exclusive end of epochs to read. To read records in unsafe epochs, specify a future epoch, larger than the current grace epoch (remember, it's exclusive end). If not specified, all safe epochs (fast, but does not return records being added). |
[in] | node_filter | If specified, returns records only in the given node. negative for reading from all nodes. This is especially useful for parallelizing a scan on a large sequential storage. |
Default parameter: the system-initial epoch for from_epoch and current-global epoch for to_epoch (thus safe_epoch_only_). Assuming this storage is used for log/archive data, this should be a quite common usecase. order_mode is defaulted to kNodeFirstMode.
Definition at line 50 of file sequential_cursor.cpp.
References ASSERT_ND, foedus::xct::XctManager::get_current_grace_epoch(), foedus::xct::Xct::get_isolation_level(), foedus::Engine::get_xct_manager(), foedus::Epoch::is_valid(), foedus::storage::kPageSize, and foedus::xct::kSnapshot.
foedus::storage::sequential::SequentialCursor::~SequentialCursor | ( | ) |
Definition at line 114 of file sequential_cursor.cpp.
|
inline |
Definition at line 142 of file sequential_cursor.hpp.
|
inline |
Definition at line 146 of file sequential_cursor.hpp.
Referenced by foedus::storage::sequential::operator<<().
|
inline |
Definition at line 143 of file sequential_cursor.hpp.
Referenced by foedus::storage::sequential::operator<<().
|
inline |
Definition at line 148 of file sequential_cursor.hpp.
Referenced by foedus::storage::sequential::operator<<().
|
inline |
Definition at line 170 of file sequential_cursor.hpp.
|
inline |
Followings are rather implementation details. Used only from testcases.
Definition at line 169 of file sequential_cursor.hpp.
|
inline |
Definition at line 171 of file sequential_cursor.hpp.
|
inline |
Definition at line 164 of file sequential_cursor.hpp.
Referenced by next_batch().
ErrorCode foedus::storage::sequential::SequentialCursor::next_batch | ( | SequentialRecordIterator * | out | ) |
Returns a batch of records as an iterator.
[out] | out | an iterator over returned records. |
It might return an empty batch even when this cursor has more records to return. Invoke is_valid() to check it. This method does nothing if is_valid() is already false. Each batch is guaranteed to be from one node, and actually from one page.
Definition at line 159 of file sequential_cursor.cpp.
References ASSERT_ND, CHECK_ERROR_CODE, is_valid(), foedus::kErrorCodeOk, and foedus::storage::sequential::SequentialRecordIterator::reset().
|
friend |
Definition at line 652 of file sequential_cursor.cpp.