18 #ifndef FOEDUS_STORAGE_ARRAY_LOG_TYPES_HPP_
19 #define FOEDUS_STORAGE_ARRAY_LOG_TYPES_HPP_
84 inline static
int compare_logs(
87 ASSERT_ND(left->header_.storage_id_ == right->header_.storage_id_);
91 if (left->offset_ != right->offset_) {
92 if (left->offset_ < right->offset_) {
98 return left->header_.xct_id_.compare_epoch_and_orginal(right->header_.xct_id_);
111 uint16_t payload_offset_;
112 uint16_t payload_count_;
115 static uint16_t calculate_log_length(uint16_t payload_count)
ALWAYS_INLINE {
124 uint16_t payload_offset,
128 template <
typename T>
129 void populate_primitive(
185 uint16_t payload_offset_;
186 uint16_t value_type_;
189 static uint16_t calculate_log_length(
ValueType value_type) ALWAYS_INLINE {
190 if (value_type <
kI64) {
197 template <
typename T>
234 uint16_t payload_offset,
235 uint16_t payload_count) {
240 payload_offset_ = payload_offset;
241 payload_count_ = payload_count;
242 std::memcpy(payload_, payload, payload_count);
245 template <
typename T>
250 uint16_t payload_offset) {
255 payload_offset_ = payload_offset;
256 payload_count_ =
sizeof(T);
257 T* address =
reinterpret_cast<T*
>(payload_);
265 char* payload)
const {
267 std::memcpy(payload + payload_offset_, payload_, payload_count_);
276 template <
typename T>
281 uint16_t payload_offset) {
287 payload_offset_ = payload_offset;
290 T* address =
reinterpret_cast<T*
>(addendum_ + 4);
293 T* address =
reinterpret_cast<T*
>(addendum_);
298 template <
typename T>
300 *payload += *addendum;
307 char* payload)
const {
308 switch (get_value_type()) {
312 reinterpret_cast<int8_t*
>(payload + payload_offset_),
313 reinterpret_cast<const int8_t*>(addendum_));
317 reinterpret_cast<int16_t*
>(payload + payload_offset_),
318 reinterpret_cast<const int16_t*>(addendum_));
322 reinterpret_cast<int32_t*
>(payload + payload_offset_),
323 reinterpret_cast<const int32_t*>(addendum_));
328 reinterpret_cast<uint8_t*
>(payload + payload_offset_),
329 reinterpret_cast<const uint8_t*>(addendum_));
333 reinterpret_cast<uint16_t*
>(payload + payload_offset_),
334 reinterpret_cast<const uint16_t*>(addendum_));
338 reinterpret_cast<uint32_t*
>(payload + payload_offset_),
339 reinterpret_cast<const uint32_t*>(addendum_));
343 reinterpret_cast<float*
>(payload + payload_offset_),
344 reinterpret_cast<const float*>(addendum_));
350 reinterpret_cast<int64_t*
>(payload + payload_offset_),
351 reinterpret_cast<const int64_t*>(addendum_ + 4));
355 reinterpret_cast<uint64_t*
>(payload + payload_offset_),
356 reinterpret_cast<const uint64_t*>(addendum_ + 4));
360 reinterpret_cast<double*
>(payload + payload_offset_),
361 reinterpret_cast<const double*>(addendum_ + 4));
369 template <
typename T>
370 inline void add_to(
void* destination,
const void* added) {
371 *(
reinterpret_cast< T*
>(destination)) += *(
reinterpret_cast< const T*
>(added));
378 switch (get_value_type()) {
381 add_to<int8_t>(addendum_, other.
addendum_);
384 add_to<int16_t>(addendum_, other.
addendum_);
387 add_to<int32_t>(addendum_, other.
addendum_);
391 add_to<uint8_t>(addendum_, other.
addendum_);
394 add_to<uint16_t>(addendum_, other.
addendum_);
397 add_to<uint32_t>(addendum_, other.
addendum_);
400 add_to<float>(addendum_, other.
addendum_);
405 add_to<int64_t>(addendum_64(), other.
addendum_64());
408 add_to<uint64_t>(addendum_64(), other.
addendum_64());
411 add_to<double>(addendum_64(), other.
addendum_64());
429 #endif // FOEDUS_STORAGE_ARRAY_LOG_TYPES_HPP_
ValueType to_value_type< int16_t >()
Base class for log type of storage-wide operation.
ValueType to_value_type< uint64_t >()
T align8(T value)
8-alignment.
Definitions of IDs in this package and a few related constant values.
uint32_t StorageId
Unique ID for storage.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Represents one thread running on one NUMA core.
ValueType to_value_type< double >()
ValueType to_value_type< int32_t >()
uint64_t ArrayOffset
The only key type in array storage.
void apply_record(thread::Thread *context, StorageId storage_id, xct::RwLockableXctId *owner_id, char *payload) const __attribute__((always_inline))
void populate_primitive(StorageId storage_id, ArrayOffset offset, T payload, uint16_t payload_offset) __attribute__((always_inline))
For primitive types.
void add_to(void *destination, const void *added)
Forward declarations of classes in array storage package.
ValueType to_value_type< float >()
void assert_valid() const __attribute__((always_inline))
bool is_64b_type() const __attribute__((always_inline))
Declares common log types used in all packages.
ValueType to_value_type< int8_t >()
const uint16_t kDataSize
Byte size of data region in each page of array storage.
ValueType to_value_type< bool >()
0x0023 : foedus::storage::array::ArrayIncrementLogType .
0x0022 : foedus::storage::array::ArrayOverwriteLogType .
void apply_record(thread::Thread *context, StorageId storage_id, xct::RwLockableXctId *owner_id, char *payload) const __attribute__((always_inline))
ValueType to_value_type< uint32_t >()
ValueType to_value_type< uint16_t >()
A base class for ArrayOverwriteLogType/ArrayIncrementLogType.
void apply_storage(Engine *engine, StorageId storage_id)
The MCS reader-writer lock variant of LockableXctId.
ValueType to_value_type< int64_t >()
Log type of array-storage's overwrite operation.
Definitions of IDs in this package and a few related constant values.
void merge(const ArrayIncrementLogType &other) __attribute__((always_inline))
A special optimization for increment logs in log gleaner.
Database engine object that holds all resources and provides APIs.
ValueType to_value_type< uint8_t >()
Log type of array-storage's increment operation.
void apply_record(thread::Thread *, storage::StorageId, xct::RwLockableXctId *, char *)
Log type of CREATE ARRAY STORAGE operation.
void populate(StorageId storage_id, ArrayOffset offset, T payload, uint16_t payload_offset) __attribute__((always_inline))
const void * addendum_64() const
ValueType
Used in ArrayIncrementLogType.
#define LOG_TYPE_NO_CONSTRUCT(clazz)
Macro to delete all constructors/destructors to prevent misuse for log type classes.
Atomic fence methods and load/store with fences that work for both C++11/non-C++11 code...
void assert_valid() const __attribute__((always_inline))
Definitions of IDs in this package and a few related constant values.
ValueType get_value_type() const __attribute__((always_inline))
ValueType to_value_type()
void increment(T *payload, const T *addendum)
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
void assert_valid_generic() __attribute__((always_inline))
Verifies the log contains essential fields set.