18 #ifndef FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_CURSOR_HPP_
19 #define FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_CURSOR_HPP_
43 namespace sequential {
134 uint64_t buffer_size,
138 int32_t node_filter = -1);
165 return !(finished_snapshots_ && finished_safe_volatiles_ && finished_unsafe_volatiles_);
182 explicit NodeState(uint16_t node_id);
186 return snapshot_heads_[snapshot_cur_head_];
189 const uint16_t node_id_;
190 uint16_t volatile_cur_core_;
196 uint32_t snapshot_cur_head_;
202 uint32_t snapshot_cur_buffer_;
208 uint32_t snapshot_buffered_pages_;
213 uint64_t snapshot_buffer_begin_;
217 std::vector<HeadPagePointer> snapshot_heads_;
224 std::vector<SequentialPage*> volatile_cur_pages_;
230 ErrorCode next_batch_snapshot(SequentialRecordIterator* out,
bool* found);
231 ErrorCode next_batch_safe_volatiles(SequentialRecordIterator* out,
bool* found);
232 ErrorCode next_batch_unsafe_volatiles(SequentialRecordIterator* out,
bool* found);
238 ErrorCode buffer_snapshot_pages(uint16_t node);
241 SequentialPage* resolve_volatile(VolatilePagePointer pointer)
const;
243 void refresh_grace_epoch();
247 enum VolatileCheckPageResult {
254 VolatileCheckPageResult next_batch_safe_volatiles_check_page(
const SequentialPage* page)
const;
256 VolatileCheckPageResult next_batch_unsafe_volatiles_check_page(
const SequentialPage* page)
const;
258 thread::Thread*
const context_;
259 xct::Xct*
const xct_;
260 Engine*
const engine_;
261 const memory::GlobalVolatilePageResolver& resolver_;
262 sequential::SequentialStorage
const storage_;
272 const Epoch to_epoch_;
274 const Epoch latest_snapshot_epoch_;
281 const Epoch from_epoch_volatile_;
287 Epoch truncate_epoch_;
289 const int32_t node_filter_;
290 const uint16_t node_count_;
301 bool safe_epoch_only_;
303 SequentialRecordBatch*
const buffer_;
304 const uint64_t buffer_size_;
306 const uint32_t buffer_pages_;
311 uint16_t current_node_;
314 bool finished_snapshots_;
316 bool finished_safe_volatiles_;
318 bool finished_unsafe_volatiles_;
324 std::vector<NodeState> states_;
362 return reinterpret_cast<const uint16_t*
>(data_ +
sizeof(
data_))[-index - 1];
395 if (
UNLIKELY(cur_record_ + 1U >= record_count_)) {
396 cur_record_ = record_count_;
409 ++stat_skipped_records_;
414 return cur_record_length_;
418 return cur_record_epoch_;
428 uint16_t copy_size = std::min<uint16_t>(out_size, cur_record_length_);
429 std::memcpy(out, raw, copy_size);
445 return epoch >= from_epoch_ && epoch < to_epoch_;
459 Epoch cur_record_epoch_;
460 uint16_t record_count_;
461 uint16_t cur_record_;
462 uint16_t cur_record_length_;
463 uint16_t cur_offset_;
464 uint16_t stat_skipped_records_;
473 #endif // FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_CURSOR_HPP_
A cursor interface to read tuples from a sequential storage.
Epoch get_from_epoch() const
T align8(T value)
8-alignment.
const xct::RwLockableXctId * get_cur_record_owner_id() const __attribute__((always_inline))
Represents a pointer to another page (usually a child page).
OrderMode
The order this cursor returns tuples.
Definitions of IDs in this package and a few related constant values.
uint16_t used_data_bytes_
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Represents one thread running on one NUMA core.
Returns as many records as possible from node-0's core-0, core-1, do the same from node-1...
const xct::RwLockableXctId * get_owner_id_from_offset(uint16_t offset) const
Forward declarations of classes in transaction package.
DualPagePointer next_page_
Pointer to next page.
void copy_cur_record(char *out, uint16_t out_size) const __attribute__((always_inline))
Copies the current record to the given buffer.
void next() __attribute__((always_inline))
XctId xct_id_
the second 64bit: Persistent status part of TID.
Returns records loosely ordered by epochs.
const char * get_cur_record_raw() const __attribute__((always_inline))
Directly returns a pointer to the current record.
bool is_valid() const __attribute__((always_inline))
#define LIKELY(x)
Hints that x is highly likely true.
Epoch get_cur_record_epoch() const __attribute__((always_inline))
Each pointer to a snapshot head page comes with a bit more information to help reading.
Epoch get_epoch_from_offset(uint16_t offset) const
The MCS reader-writer lock variant of LockableXctId.
bool in_epoch_range(Epoch epoch) const __attribute__((always_inline))
const char * get_payload_from_offset(uint16_t offset) const
Represents an append/scan-only store.
ErrorCode next_batch(SequentialRecordIterator *out)
Returns a batch of records as an iterator.
Forward declarations of classes in sequential storage package.
uint16_t get_stat_skipped_records() const
Definitions of IDs in this package and a few related constant values.
bool is_finished_snapshots() const
Followings are rather implementation details. Used only from testcases.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
thread::Thread * get_context() const
Epoch get_epoch() const __attribute__((always_inline))
Definitions of IDs in this package and a few related constant values.
Forward declarations of classes in memory package.
const sequential::SequentialStorage & get_storage() const
Epoch get_to_epoch() const
bool is_finished_unsafe_volatiles() const
const SequentialRecordBatch * get_raw_batch() const
SequentialRecordIterator()
uint16_t get_record_count() const
const Epoch INVALID_EPOCH
A constant epoch object that represents an invalid epoch.
char data_[kDataSize]
Dynamic data part in this page, which consist of 1) record part growing forward, 2) unused part...
uint16_t get_record_count() const
const uint16_t kDataSize
Byte size of data region in each data page of sequential storage.
#define STATIC_SIZE_CHECK(desired, actual)
Iterator for one SequentialRecordBatch, or a page.
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.
#define UNLIKELY(x)
Hints that x is highly likely false.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Forward declarations of classes in thread package.
uint16_t get_record_length(uint16_t index) const
A chunk of records returned by SequentialCursor.
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
uint16_t get_cur_record_length() const __attribute__((always_inline))
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
ErrorCode
Enum of error codes defined in error_code.xmacro.
friend std::ostream & operator<<(std::ostream &o, const SequentialCursor &v)
bool is_finished_safe_volatiles() const