libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

Defines the content and apply logic of transactional operatrions. More...

Detailed Description

Defines the content and apply logic of transactional operatrions.

Each loggable operation defines a struct XxxLogType that has the following methods:

For non-applicable apply-type, the implmentation class should abort. Remember that these are all non-virtual methods. See the next section for more details.

No polymorphism
There is no polymorphism guaranteed for log types. Because we read/write just a bunch of bytes and do reinterpret_cast, there is no dynamic type information. We of course can't afford instantiating objects for each log entry, either. Do not use any override in log type classes. You should even delete all constructors to avoid misuse (see LOG_TYPE_NO_CONSTRUCT(clazz) ). We do have base classes (EngineLogType, StorageLogType, and RecordLogType), but this is only to reduce typing. No virtual methods.
Current List of LogType
See foedus::log::LogCode
log_type.hpp and log_type_invoke.hpp
This file defines only log codes and names, so quite compact even after preprocessing. On the other hand, log_type_invoke.hpp defines more methods that need to include a few more headers, so its size is quite big after proprocessing. Most places should need only log_type.hpp. Include log_type_invoke.hpp only where we invoke apply/ostream etc.
Collaboration diagram for Log Types:

Classes

struct  foedus::log::LogHeader
 A common header part for all log types. More...
 
struct  foedus::log::BaseLogType
 Base class for log type. More...
 
struct  foedus::log::EngineLogType
 Base class for log type of engine-wide operation. More...
 
struct  foedus::log::StorageLogType
 Base class for log type of storage-wide operation. More...
 
struct  foedus::log::RecordLogType
 Base class for log type of record-wise operation. More...
 
struct  foedus::log::FillerLogType
 A dummy log type to fill up a sector in log files. More...
 
struct  foedus::log::EpochMarkerLogType
 A log type to declare a switch of epoch in a logger or the engine. More...
 
struct  foedus::storage::array::ArrayCreateLogType
 Log type of CREATE ARRAY STORAGE operation. More...
 
struct  foedus::storage::array::ArrayCommonUpdateLogType
 A base class for ArrayOverwriteLogType/ArrayIncrementLogType. More...
 
struct  foedus::storage::array::ArrayOverwriteLogType
 Log type of array-storage's overwrite operation. More...
 
struct  foedus::storage::array::ArrayIncrementLogType
 Log type of array-storage's increment operation. More...
 
struct  foedus::storage::hash::HashCreateLogType
 Log type of CREATE HASH STORAGE operation. More...
 
struct  foedus::storage::hash::HashCommonLogType
 A base class for HashInsertLogType/HashDeleteLogType/HashOverwriteLogType. More...
 
struct  foedus::storage::hash::HashInsertLogType
 Log type of hash-storage's insert operation. More...
 
struct  foedus::storage::hash::HashDeleteLogType
 Log type of hash-storage's delete operation. More...
 
struct  foedus::storage::hash::HashUpdateLogType
 Log type of hash-storage's update operation. More...
 
struct  foedus::storage::hash::HashOverwriteLogType
 Log type of hash-storage's overwrite operation. More...
 
struct  foedus::storage::masstree::MasstreeCreateLogType
 Log type of CREATE MASSTREE STORAGE operation. More...
 
struct  foedus::storage::masstree::MasstreeCommonLogType::RecordAddresses
 
struct  foedus::storage::masstree::MasstreeCommonLogType
 A base class for MasstreeInsertLogType/MasstreeDeleteLogType/MasstreeOverwriteLogType. More...
 
struct  foedus::storage::masstree::MasstreeInsertLogType
 Log type of masstree-storage's insert operation. More...
 
struct  foedus::storage::masstree::MasstreeDeleteLogType
 Log type of masstree-storage's delete operation. More...
 
struct  foedus::storage::masstree::MasstreeUpdateLogType
 Log type of masstree-storage's update operation. More...
 
struct  foedus::storage::masstree::MasstreeOverwriteLogType
 Log type of masstree-storage's overwrite operation. More...
 
struct  foedus::storage::sequential::SequentialCreateLogType
 Log type of CREATE SEQUENTIAL STORAGE operation. More...
 
struct  foedus::storage::sequential::SequentialTruncateLogType
 Log type of TRUNCATE SEQUENTIAL STORAGE operation. More...
 
struct  foedus::storage::sequential::SequentialAppendLogType
 Log type of sequential-storage's append operation. More...
 
struct  foedus::storage::DropLogType
 Log type of DROP STORAGE operation. More...
 
struct  foedus::storage::CreateLogType
 Base type for CREATE STORAGE operation. More...
 

Macros

#define LOG_TYPE_NO_CONSTRUCT(clazz)
 Macro to delete all constructors/destructors to prevent misuse for log type classes. More...
 

Enumerations

enum  foedus::log::LogCode {
  foedus::log::kLogCodeInvalid = 0, foedus::log::kLogCodeFiller = 0x3001, foedus::log::kLogCodeEpochMarker = 0x3002, foedus::log::kLogCodeDropLogType = 0x1011,
  foedus::log::kLogCodeArrayCreate = 0x1021, foedus::log::kLogCodeArrayOverwrite = 0x0022, foedus::log::kLogCodeArrayIncrement = 0x0023, foedus::log::kLogCodeSequentialTruncate = 0x1024,
  foedus::log::kLogCodeSequentialCreate = 0x1025, foedus::log::kLogCodeSequentialAppend = 0x0026, foedus::log::kLogCodeHashCreate = 0x1027, foedus::log::kLogCodeHashOverwrite = 0x0028,
  foedus::log::kLogCodeHashInsert = 0x0029, foedus::log::kLogCodeHashDelete = 0x002A, foedus::log::kLogCodeHashUpdate = 0x002B, foedus::log::kLogCodeMasstreeCreate = 0x1031,
  foedus::log::kLogCodeMasstreeOverwrite = 0x0032, foedus::log::kLogCodeMasstreeInsert = 0x0033, foedus::log::kLogCodeMasstreeDelete = 0x0034, foedus::log::kLogCodeMasstreeUpdate = 0x0035
}
 A unique identifier of all log types. More...
 
enum  foedus::log::LogCodeKind { foedus::log::kRecordLogs = 0, foedus::log::kStorageLogs = 1, foedus::log::kEngineLogs = 2, foedus::log::kMarkerLogs = 3 }
 Represents the kind of log types. More...
 

Functions

LogCodeKind foedus::log::get_log_code_kind (LogCode code)
 Returns the kind of the given log code. More...
 
bool foedus::log::is_valid_log_type (LogCode code)
 Returns if the LogCode value exists. More...
 
const char * foedus::log::get_log_type_name (LogCode code)
 Returns the names of LogCode enum defined in log_type.xmacro. More...
 
template<typename LOG_TYPE >
constexpr LogCode foedus::log::get_log_code ()
 Returns LogCode for the log type defined in log_type.xmacro. More...
 
void foedus::log::invoke_apply_engine (void *log_buffer, thread::Thread *context)
 Invokes the apply logic for an engine-wide log type. More...
 
void foedus::log::invoke_apply_storage (void *log_buffer, Engine *engine, storage::StorageId id)
 Invokes the apply logic for a storage-wide log type. More...
 
void foedus::log::invoke_apply_record (void *log_buffer, thread::Thread *context, storage::StorageId storage_id, xct::RwLockableXctId *owner_id_address, char *payload_address)
 Invokes the apply logic for a record-wise log type. More...
 
void foedus::log::invoke_assert_valid (void *log_buffer)
 Invokes the assertion logic of each log type. More...
 
void foedus::log::invoke_ostream (const void *buffer, std::ostream *ptr)
 Invokes the ostream operator for the given log type defined in log_type.xmacro. More...
 

Class Documentation

struct foedus::storage::masstree::MasstreeCommonLogType::RecordAddresses

Definition at line 211 of file masstree_log_types.hpp.

Class Members
char * record_payload_
PayloadLength * record_payload_count_

Macro Definition Documentation

#define LOG_TYPE_NO_CONSTRUCT (   clazz)
Value:
clazz(const clazz &other) CXX11_FUNC_DELETE;\
~clazz() CXX11_FUNC_DELETE;
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128

Macro to delete all constructors/destructors to prevent misuse for log type classes.

Definition at line 103 of file common_log_types.hpp.

Enumeration Type Documentation

A unique identifier of all log types.

Log code values must follow the convention. Most significant 4 bits are used to denote the kind of the log:

  • 0x0000: record targetted logs
  • 0x1000: storage targetted logs
  • 0x2000: engine targetted logs
  • 0x3000: markers/fillers
  • ~0xF000 (reserved for future use)
Enumerator
kLogCodeInvalid 

0 is reserved as a non-existing log type.

kLogCodeFiller 

0x3001 : foedus::log::FillerLogType .

A dummy log type to fill up a sector in log files. As we do direct I/O, we must do file I/O in multiply of 4kb. We pad the log buffer we are about to write with this log type. Log gleaner simply skips this log. This is the only log type whose size might be smaller than sizeof(FillerLogType). This happens because the common log header is 16 bytes but we have to make this log type 8 bytes able to fill every gap. For this reason, the xct_id_ property of this log must not be used.

kLogCodeEpochMarker 

0x3002 : foedus::log::EpochMarkerLogType .

A log type to declare a switch of epoch in a logger or the engine. Each logger puts this marker when it switches epoch. When applied, this just adds epoch switch history which is maintained until related logs are gleaned and garbage collected.

The epoch switch history is used to efficiently identify the beginning of each epoch in each logger. This is useful for example when we take samples from each epoch.

Now that we contain XctId in every log, it's not necessary to put this marker. However, having this log makes a few things easier; the epoch history management for seeking to beginning of a specific epoch and several sanity checks. So, we still keep this log. It's anyway only occadionally written, so no harm. Every log file starts with an epoch mark for this reason, too.

kLogCodeDropLogType 

0x1011 : foedus::storage::DropLogType .

Log type of DROP STORAGE operation. This log corresponds to StorageManager::drop_storage() opereation. DROP STORAGE has no in-epoch transaction order. It is always processed in a separate epoch from operations for the storage. Thus, we advance epoch before and after dropping a storage.

kLogCodeArrayCreate 

0x1021 : foedus::storage::array::ArrayCreateLogType .

Log type of CREATE ARRAY STORAGE operation. This log corresponds to StorageManager::create_array() opereation. CREATE ARRAY STORAGE has no in-epoch transaction order. It is always processed in a separate epoch from operations for the storage. Thus, we advance epoch right after creating a storage (before following operations).

This log type is infrequently triggered, so no optimization. All methods defined in cpp.

kLogCodeArrayOverwrite 

0x0022 : foedus::storage::array::ArrayOverwriteLogType .

Log type of array-storage's overwrite operation. This is a modification operation in array. It simply invokes memcpy to the payload.

kLogCodeArrayIncrement 

0x0023 : foedus::storage::array::ArrayIncrementLogType .

Log type of array-storage's increment operation. This is similar to overwrite, but different in a sense that this can do value-increment without relying on the current value. For that, we remember the addendum in primitive format.

kLogCodeSequentialTruncate 

0x1024 : foedus::storage::sequential::SequentialTruncateLogType .

Log type of TRUNCATE SEQUENTIAL STORAGE operation. This log corresponds to SequentialStorage::truncate() operation. Like SequentialCreateLogType, this is a metadata operation.

This log type is infrequently triggered, so no optimization. All methods defined in cpp.

kLogCodeSequentialCreate 

0x1025 : foedus::storage::sequential::SequentialCreateLogType .

Log type of CREATE SEQUENTIAL STORAGE operation. This log corresponds to StorageManager::create_sequential() operation. CREATE STORAGE has no in-epoch transaction order. It is always processed in a separate epoch from operations for the storage. Thus, we advance epoch right after creating a storage (before following operations).

This log type is infrequently triggered, so no optimization. All methods defined in cpp.

kLogCodeSequentialAppend 

0x0026 : foedus::storage::sequential::SequentialAppendLogType .

Log type of sequential-storage's append operation. This is the only record-level operation in sequential storage. It simply appends the the end with an atomic operation.

kLogCodeHashCreate 

0x1027 : foedus::storage::hash::HashCreateLogType .

Log type of CREATE HASH STORAGE operation. This log corresponds to StorageManager::create_hash() opereation. CREATE HASH STORAGE has no in-epoch transaction order. It is always processed in a separate epoch from operations for the storage. Thus, we advance epoch right after creating a storage (before following operations).

This log type is infrequently triggered, so no optimization. All methods defined in cpp.

kLogCodeHashOverwrite 

0x0028 : foedus::storage::hash::HashOverwriteLogType .

Log type of hash-storage's overwrite operation. This is one of the modification operations in hash. It simply invokes memcpy to the payload.

kLogCodeHashInsert 

0x0029 : foedus::storage::hash::HashInsertLogType .

Log type of hash-storage's insert operation. Applying this log just flips the delete flag and installs the payload. Allocating the slot and modifying the bloom filter is already done by a system transaction.

kLogCodeHashDelete 

0x002A : foedus::storage::hash::HashDeleteLogType .

Log type of hash-storage's delete operation. This one does nothing but flipping delete bit.

kLogCodeHashUpdate 

0x002B : foedus::storage::hash::HashUpdateLogType .

Log type of hash-storage's update operation. Applying this log changes the logical payload size and installs the payload, keeping the delete flag (which must be false). Allocating the slot and modifying the bloom filter is already done by a system transaction. Also, the record's physical size must be guaranteed to be enough spacious.

kLogCodeMasstreeCreate 

0x1031 : foedus::storage::masstree::MasstreeCreateLogType .

Log type of CREATE MASSTREE STORAGE operation. This log corresponds to StorageManager::create_masstree() opereation. CREATE STORAGE has no in-epoch transaction order. It is always processed in a separate epoch from operations for the storage. Thus, we advance epoch right after creating a storage (before following operations).

This log type is infrequently triggered, so no optimization. All methods defined in cpp.

kLogCodeMasstreeOverwrite 

0x0032 : foedus::storage::masstree::MasstreeOverwriteLogType .

Log type of masstree-storage's overwrite operation. Same as insert log.

kLogCodeMasstreeInsert 

0x0033 : foedus::storage::masstree::MasstreeInsertLogType .

Log type of masstree-storage's insert operation. This is different from hash. In MasstreeBorderPage, we atomically increment the physical record count, set the key, set slot, leaves it as deleted, then unlock the page lock. When we get to here, the record already has key set and has reserved slot.

kLogCodeMasstreeDelete 

0x0034 : foedus::storage::masstree::MasstreeDeleteLogType .

Log type of masstree-storage's delete operation. This one does nothing but flipping delete bit.

kLogCodeMasstreeUpdate 

0x0035 : foedus::storage::masstree::MasstreeUpdateLogType .

Log type of masstree-storage's update operation. Almost same as insert except this keeps the delete-flag, which must be off.

Definition at line 87 of file log_type.hpp.

87  {
89  kLogCodeInvalid = 0,
90 #include "foedus/log/log_type.xmacro" // NOLINT
91 };
0 is reserved as a non-existing log type.
Definition: log_type.hpp:89

Represents the kind of log types.

This is the most significant 4 bits of LogCode.

Enumerator
kRecordLogs 

record targetted logs

kStorageLogs 

storage targetted logs

kEngineLogs 

engine targetted logs

kMarkerLogs 

markers/fillers

Definition at line 101 of file log_type.hpp.

101  {
103  kRecordLogs = 0,
105  kStorageLogs = 1,
107  kEngineLogs = 2,
109  kMarkerLogs = 3,
110 };
markers/fillers
Definition: log_type.hpp:109
record targetted logs
Definition: log_type.hpp:103
engine targetted logs
Definition: log_type.hpp:107
storage targetted logs
Definition: log_type.hpp:105

Function Documentation

template<typename LOG_TYPE >
constexpr LogCode foedus::log::get_log_code ( )

Returns LogCode for the log type defined in log_type.xmacro.

This is inlined below because it's called VERY frequently. This method is declared as constexpr if C++11 is enabled, in which case there should be really no overheads to call this method.

LogCodeKind foedus::log::get_log_code_kind ( LogCode  code)
inline

Returns the kind of the given log code.

This is inlined here because it's called frequently.

Definition at line 118 of file log_type.hpp.

Referenced by foedus::log::LogHeader::get_kind().

118  {
119  return static_cast<LogCodeKind>(code >> 12);
120 }
LogCodeKind
Represents the kind of log types.
Definition: log_type.hpp:101

Here is the caller graph for this function:

const char * foedus::log::get_log_type_name ( LogCode  code)

Returns the names of LogCode enum defined in log_type.xmacro.

This is NOT inlined because this is used only in debugging situation.

Definition at line 28 of file log_type.cpp.

References foedus::log::kLogCodeInvalid.

Referenced by foedus::log::operator<<().

28  {
29  switch (code) {
30  case kLogCodeInvalid: return "kLogCodeInvalid";
31 #include "foedus/log/log_type.xmacro" // NOLINT
32  default: return "UNKNOWN";
33  }
34 }
0 is reserved as a non-existing log type.
Definition: log_type.hpp:89

Here is the caller graph for this function:

void foedus::log::invoke_apply_engine ( void *  log_buffer,
thread::Thread context 
)

Invokes the apply logic for an engine-wide log type.

This is not inlined because this log kind appears much more infrequently.

Definition at line 26 of file log_type_invoke.cpp.

References ASSERT_ND, foedus::log::LogHeader::get_type(), and foedus::log::invoke_assert_valid().

26  {
27  invoke_assert_valid(buffer);
28  LogHeader* header = reinterpret_cast<LogHeader*>(buffer);
29  LogCode code = header->get_type();
30  switch (code) {
31 #include "foedus/log/log_type.xmacro" // NOLINT
32  default:
33  ASSERT_ND(false);
34  return;
35  }
36 }
LogCode
A unique identifier of all log types.
Definition: log_type.hpp:87
void invoke_assert_valid(void *log_buffer)
Invokes the assertion logic of each log type.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

void foedus::log::invoke_apply_record ( void *  log_buffer,
thread::Thread context,
storage::StorageId  storage_id,
xct::RwLockableXctId owner_id_address,
char *  payload_address 
)
inline

Invokes the apply logic for a record-wise log type.

This is inlined because this is invoked for every single record type log.

Definition at line 89 of file log_type_invoke.hpp.

References ASSERT_ND, foedus::log::LogHeader::get_type(), and foedus::log::invoke_assert_valid().

Referenced by foedus::xct::XctManagerPimpl::precommit_xct_apply().

94  {
95  invoke_assert_valid(buffer);
96  LogHeader* header = reinterpret_cast<LogHeader*>(buffer);
97  LogCode code = header->get_type();
98  switch (code) {
99 #include "foedus/log/log_type.xmacro" // NOLINT
100  default:
101  ASSERT_ND(false);
102  return;
103  }
104 }
LogCode
A unique identifier of all log types.
Definition: log_type.hpp:87
void invoke_assert_valid(void *log_buffer)
Invokes the assertion logic of each log type.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::log::invoke_apply_storage ( void *  log_buffer,
Engine engine,
storage::StorageId  id 
)

Invokes the apply logic for a storage-wide log type.

This is not inlined because this log kind appears much more infrequently.

Definition at line 41 of file log_type_invoke.cpp.

References ASSERT_ND, foedus::log::LogHeader::get_type(), and foedus::log::invoke_assert_valid().

41  {
42  invoke_assert_valid(buffer);
43  LogHeader* header = reinterpret_cast<LogHeader*>(buffer);
44  LogCode code = header->get_type();
45  switch (code) {
46 #include "foedus/log/log_type.xmacro" // NOLINT
47  default:
48  ASSERT_ND(false);
49  return;
50  }
51 }
LogCode
A unique identifier of all log types.
Definition: log_type.hpp:87
void invoke_assert_valid(void *log_buffer)
Invokes the assertion logic of each log type.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

void foedus::log::invoke_assert_valid ( void *  log_buffer)
inline

Invokes the assertion logic of each log type.

This is inlined because this is invoked for every single record type log. In non-debug mode, this is anyway empty.

Definition at line 111 of file log_type_invoke.hpp.

References ASSERT_ND, and foedus::log::LogHeader::get_type().

Referenced by foedus::xct::Xct::add_related_write_set(), foedus::xct::Xct::add_to_lock_free_write_set(), foedus::xct::Xct::add_to_read_and_write_set(), foedus::xct::Xct::add_to_write_set(), foedus::log::invoke_apply_engine(), foedus::log::invoke_apply_record(), and foedus::log::invoke_apply_storage().

111  {
112  LogHeader* header = reinterpret_cast<LogHeader*>(buffer);
113  LogCode code = header->get_type();
114  switch (code) {
115 #include "foedus/log/log_type.xmacro" // NOLINT
116  default:
117  ASSERT_ND(false);
118  return;
119  }
120 }
LogCode
A unique identifier of all log types.
Definition: log_type.hpp:87
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::log::invoke_ostream ( const void *  buffer,
std::ostream *  ptr 
)

Invokes the ostream operator for the given log type defined in log_type.xmacro.

This is only for debugging and analysis use, so does not have to be optimized. Thus not inlined here. This writes out an XML representation of the log entry.

Definition at line 56 of file log_type_invoke.cpp.

References foedus::log::LogHeader::get_type(), and foedus::log::kLogCodeInvalid.

Referenced by foedus::log::on_non_durable_meta_log_found(), and foedus::xct::operator<<().

56  {
57  const LogHeader* header = reinterpret_cast<const LogHeader*>(buffer);
58  LogCode code = header->get_type();
59  std::ostream &o = *ptr;
60  switch (code) {
61  case kLogCodeInvalid: break;
62 #include "foedus/log/log_type.xmacro" // NOLINT
63  }
64 }
LogCode
A unique identifier of all log types.
Definition: log_type.hpp:87
0 is reserved as a non-existing log type.
Definition: log_type.hpp:89

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::log::is_valid_log_type ( LogCode  code)
inline

Returns if the LogCode value exists.

This is inlined here because it's called frequently.

Definition at line 128 of file log_type.hpp.

Referenced by foedus::log::LogHeader::is_valid_type().

128  {
129  switch (code) {
130 #define X(a, b, c) case a: return true;
131 #include "foedus/log/log_type.xmacro" // NOLINT
132 #undef X
133  default: return false;
134  }
135 }

Here is the caller graph for this function: