18 #ifndef FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_PAGE_IMPL_HPP_
19 #define FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_PAGE_IMPL_HPP_
37 namespace sequential {
89 const PayloadLength* lengthes =
reinterpret_cast<const PayloadLength*
>(data_ +
kDataSize);
90 PayloadLength length = *(lengthes - 1 - record);
96 PayloadLength* lengthes =
reinterpret_cast<PayloadLength*
>(data_ +
kDataSize);
97 *(lengthes - 1 - record) = length;
106 uint16_t* record_count,
107 const char** record_pointers,
108 uint16_t* payload_lengthes)
const {
111 uint16_t position = 0;
112 for (uint16_t i = 0; i < *record_count; ++i) {
113 record_pointers[i] = data_ + position;
123 for (uint16_t i = 0; i < record; ++i) {
137 used_data_bytes_ = 0;
144 used_data_bytes_ = 0;
157 uint16_t payload_length,
158 const void* payload) {
164 owner_id_addr->
xct_id_ = owner_id;
166 std::memcpy(data_ + used_data_bytes_ +
kRecordOverhead, payload, payload_length);
186 return used_data_bytes_ + record_length
187 +
sizeof(PayloadLength) * (record_count_ + 1) <=
kDataSize && record_count_ <
kMaxSlots;
210 typedef uint16_t PayloadLength;
214 uint16_t record_count_;
215 uint16_t used_data_bytes_;
267 pointer_count_ = pointer_count;
268 std::memcpy(head_page_pointers_, pointers,
sizeof(
HeadPagePointer) * pointer_count);
290 uint64_t pointer_count_;
307 #endif // FOEDUS_STORAGE_SEQUENTIAL_SEQUENTIAL_PAGE_IMPL_HPP_
void assert_consistent() const
const char * unused_dummy_func_filler() const
T align8(T value)
8-alignment.
Represents a pointer to another page (usually a child page).
Definitions of IDs in this package and a few related constant values.
const uint16_t kRecordOverhead
Byte size of system-managed region per each record.
uint32_t StorageId
Unique ID for storage.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
bool can_insert_record(uint16_t payload_length) const
Returns if this page has enough room to insert a record with the given payload length.
SequentialPage & operator=(const SequentialPage &other)=delete
Epoch get_first_record_epoch() const
Returns the epoch of the fist record in this page (undefined behavior if no record).
void get_all_records_nosync(uint16_t *record_count, const char **record_pointers, uint16_t *payload_lengthes) const
Retrieve positions and lengthes of all records in one batch.
DualPagePointer & next_page()
const PageHeader & header() const
Represents a pointer to a volatile page with modification count for preventing ABA.
Persistent status part of Transaction ID.
void append_record_nosync(xct::XctId owner_id, uint16_t payload_length, const void *payload)
Appends a record to this page.
XctId xct_id_
the second 64bit: Persistent status part of TID.
Represents one data page in Sequential Storage.
const uint16_t kRootPageMaxHeadPointers
Maximum number of head pointers in one root page.
const PageHeader & header() const
Each pointer to a snapshot head page comes with a bit more information to help reading.
McsRwLock lock_
the first 64bit: Locking part of TID
The MCS reader-writer lock variant of LockableXctId.
uint16_t get_payload_length(uint16_t record) const
Returns byte length of payload of the specified record in this page.
const xct::RwLockableXctId * owner_id_from_offset(uint16_t offset) const
SnapshotPagePointer get_next_page() const
VolatilePagePointer volatile_pointer_
xct::RwLockableXctId * owner_id_from_offset(uint16_t offset)
Definitions of IDs in this package and a few related constant values.
uint16_t get_record_offset(uint16_t record) const
Returns beginning offset of the specified record.
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
void set_next_page(SnapshotPagePointer page)
const HeadPagePointer * get_pointers() const
SnapshotPagePointer snapshot_pointer_
Epoch get_epoch() const __attribute__((always_inline))
uint16_t get_record_length(uint16_t record) const
Returns byte length of the specified record in this page.
Definitions of IDs in this package and a few related constant values.
uint16_t get_pointer_count() const
Returns How many pointers to head pages exist in this page.
Represents one stable root page in Sequential Storage.
void set_pointers(HeadPagePointer *pointers, uint16_t pointer_count)
void initialize_snapshot_page(StorageId storage_id, SnapshotPagePointer page_id)
PageVersionStatus status_
void set_payload_length(uint16_t record, uint16_t length)
Sets byte length of payload of the specified record in this page.
uint16_t get_record_count() const
Returns how many records in this page placed so far.
const DualPagePointer & next_page() const
Atomic fence methods and load/store with fences that work for both C++11/non-C++11 code...
const uint16_t kDataSize
Byte size of data region in each data page of sequential storage.
#define STATIC_SIZE_CHECK(desired, actual)
uint32_t unused_dummy_func_filler() const
const uint16_t kRootPageHeaderSize
Byte size of header in each root page of sequential storage.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
SequentialRootPage()=delete
void initialize_snapshot_page(StorageId storage_id, SnapshotPagePointer page_id)
Called only when this page is initialized.
void memory_fence_release()
Equivalent to std::atomic_thread_fence(std::memory_order_release).
SequentialRootPage & operator=(const SequentialRootPage &other)=delete
const uint16_t kPageSize
A constant defining the page size (in bytes) of both snapshot pages and volatile pages.
const uint16_t kMaxSlots
We have to represent the record count in 15 bits.
uint16_t get_used_data_bytes() const
How many data bytes in this page consumed so far.
void increment_version_counter() __attribute__((always_inline))
void initialize_volatile_page(StorageId storage_id, VolatilePagePointer page_id)
Called only when this page is initialized.