CreDB  0.1.0
Classes | Typedefs | Enumerations | Functions | Variables
event_id.h File Reference
#include <algorithm>
#include <cstring>
#include <stdint.h>
#include <string>
#include <tuple>
#include <unordered_map>

Go to the source code of this file.

Classes

struct  event_id_t
 Specifies the position of an event on a node's ledger. More...
 
struct  event_range_t
 

Typedefs

using shard_id_t = uint16_t
 Unique identifier for a shard.
 
using block_id_t = uint32_t
 Unique identifier for a block in a shard.
 
using version_number_t = uint32_t
 Indicator of how many changes where made to an object.
 
using block_index_t = uint16_t
 Unique identifier for an event inside a block.
 
using transaction_bounds_t = std::unordered_map< shard_id_t, event_range_t >
 

Enumerations

enum  OrderResult {
  Unknown, Equal, OlderThan, NewerThan,
  Concurrent
}
 Result of an order query.
 

Functions

bool operator== (const event_id_t &lhs, const event_id_t &rhs)
 
bool operator!= (const event_id_t &lhs, const event_id_t &rhs)
 
OrderResult order (const event_id_t &first, const event_id_t &second)
 Order two event identifiers with respect to each other.
 
bool operator< (const event_id_t &first, const event_id_t &second)
 
bool operator< (const event_id_t &e, const event_range_t &range)
 
bool operator> (const event_id_t &e, const event_range_t &range)
 is an event strictly after an event range?
 
OrderResult order (const event_range_t &first, const event_range_t &second)
 Order two event ranges with respect to each other.
 
OrderResult order (const transaction_bounds_t &first, const transaction_bounds_t &second)
 

Variables

constexpr version_number_t INVALID_VERSION_NO = 0
 Constant for a invalid version.
 
constexpr version_number_t INITIAL_VERSION_NO = 1
 Constant for the initial version.
 
constexpr block_id_t INVALID_BLOCK = 0
 Constant for an Invalid block.
 
constexpr block_id_t INITIAL_BLOCK = 1
 Constant for the initial block in a shard.
 
constexpr event_id_t INVALID_EVENT
 
constexpr event_id_t UNCOMMITTED_EVENT
 

Typedef Documentation

◆ transaction_bounds_t

using transaction_bounds_t = std::unordered_map<shard_id_t, event_range_t>

Defines the extent of a transaction across the ledger

Function Documentation

◆ operator!=()

bool credb::operator!= ( const event_id_t lhs,
const event_id_t rhs 
)
inline

Compare two event identifiers for inequality

◆ operator<() [1/2]

bool credb::operator< ( const event_id_t first,
const event_id_t second 
)
inline

Is an event id older than another?

◆ operator<() [2/2]

bool credb::operator< ( const event_id_t e,
const event_range_t range 
)
inline

Is an event strictly before a specific range?

◆ operator==()

bool credb::operator== ( const event_id_t lhs,
const event_id_t rhs 
)
inline

Compare two event identifier for equality

◆ order()

OrderResult credb::order ( const transaction_bounds_t first,
const transaction_bounds_t second 
)
inline

Order two transaction bounds with respect to each other

Note
this assumes that the transaction bounds are derived from valid, committed transactions

Variable Documentation

◆ INVALID_EVENT

constexpr event_id_t INVALID_EVENT
Initial value:
= { static_cast<shard_id_t>(INVALID_BLOCK), INVALID_BLOCK,
static_cast<block_index_t>(0) }
constexpr block_id_t INVALID_BLOCK
Constant for an Invalid block.
Definition: event_id.h:39
uint16_t shard_id_t
Unique identifier for a shard.
Definition: event_id.h:21

Constant for an invalid event identifier

◆ UNCOMMITTED_EVENT

constexpr event_id_t UNCOMMITTED_EVENT
Initial value:
= { static_cast<shard_id_t>(-2), static_cast<block_id_t>(-2),
static_cast<block_index_t>(-2) }
uint16_t block_index_t
Unique identifier for an event inside a block.
Definition: event_id.h:30
uint16_t shard_id_t
Unique identifier for a shard.
Definition: event_id.h:21

Constant for an identifier for an uncommitted event

Note
this is only used in transactions