0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes | List of all members
Hypertable::MetaLog::EntityHeader Class Reference

Entity header. More...

#include <MetaLogEntityHeader.h>

Public Types

enum  { FLAG_REMOVE = 0x00000001, LENGTH = 32 }
 Enumeration for entity header constants. More...
 

Public Member Functions

 EntityHeader ()
 Constructor. More...
 
 EntityHeader (int32_t type_)
 Constructor with entity type. More...
 
 EntityHeader (const EntityHeader &other)
 Copy constructor. More...
 
bool operator< (const EntityHeader &other) const
 Less than operator for comparing this header with another. More...
 
void encode (uint8_t **bufp) const
 Encodes (serializes) header to a buffer. More...
 
void decode (const uint8_t **bufp, size_t *remainp)
 Decodes serialzed header from buffer. More...
 
void display (std::ostream &os)
 Display human-readable representation of header to an ostream. More...
 

Public Attributes

int32_t type {}
 Entity type defined within the context of a Definition More...
 
int32_t checksum {}
 Checksum of serialized entity state More...
 
int64_t id {}
 Unique ID of entity. More...
 
int64_t timestamp {}
 Creation timestmp of entity header. More...
 
int32_t flags {}
 Flags (either FLAG_REMOVE or 0) More...
 
int32_t length {}
 Length of entity header plus serialized state. More...
 

Static Public Attributes

static bool display_timestamp = true
 Controls whether or not timestamp is printed by display() More...
 

Static Private Attributes

static int64_t ms_next_id = 1
 Global counter for generating unique entity IDs More...
 
static std::mutex ms_mutex
 Mutex for serializing access to ms_next_id More...
 

Detailed Description

Entity header.

This class is used to encode and decode the serialized entity header which preceeds the serialized entity state in a MetaLog file. The id member of the header uniquely identifies an entity. Each time an entity changes state, the new state can be serialized to the MetaLog by appending it (header plus new serialized state) to the log. When the log is read, there may multiple serialized versions for the same entity (i.e. entities with the same header id field. The last serialized version of an entity is taken to be the most up-to-date version of the entity.

Definition at line 54 of file MetaLogEntityHeader.h.

Constructor & Destructor Documentation

EntityHeader::EntityHeader ( )

Constructor.

Constructs an empty object initializing all members to 0.

Definition at line 47 of file MetaLogEntityHeader.cc.

EntityHeader::EntityHeader ( int32_t  type_)

Constructor with entity type.

Constructs a new header initializing type to type_, id to ms_next_id (post-incrementing), timestamp to the current time returned by get_ts64(), and all other members to 0.

Parameters
type_Numeric entity type

Definition at line 49 of file MetaLogEntityHeader.cc.

EntityHeader::EntityHeader ( const EntityHeader other)

Copy constructor.

Constructs a header by initializing all members to the corresponding members of other. If other.id is greater than or equal to ms_next_id, ms_next_id is set to other.id+1.

Parameters
otherOther entity header from which to copy

Definition at line 57 of file MetaLogEntityHeader.cc.

Member Function Documentation

void EntityHeader::decode ( const uint8_t **  bufp,
size_t *  remainp 
)

Decodes serialzed header from buffer.

See encode() for serialization format.

Parameters
bufpAddress of destination buffer pointer (advanced by call)
remainpAddress of integer holding amount of remaining buffer, decremented by call.
See also
encode()

Definition at line 91 of file MetaLogEntityHeader.cc.

void EntityHeader::display ( std::ostream &  os)

Display human-readable representation of header to an ostream.

Prints a comma-separated list of the header members to os. If the static member display_timestamp is set to true, the timestamp is included, otherwise it is not. Tests that rely on repeatable output of entity headers for the purposes of comparison with diff can set display_timestamp to false.

Parameters
osostream on which to print header

Definition at line 101 of file MetaLogEntityHeader.cc.

void EntityHeader::encode ( uint8_t **  bufp) const

Encodes (serializes) header to a buffer.

Encoded as follows:

EncodingMember
i32type
i32checksum
i32length
i32flags
i64id
i64timestamp
Parameters
bufpAddress of destination buffer pointer (advanced by call)

Definition at line 82 of file MetaLogEntityHeader.cc.

bool EntityHeader::operator< ( const EntityHeader other) const

Less than operator for comparing this header with another.

Returns true if the id members are not equal but timestamp is less than other.timestamp, or if the timestamps are equal and id is less than other.id.

Parameters
otherOther entity for which comparison is made
Returns
true if header is less than other, false otherwise.

Definition at line 71 of file MetaLogEntityHeader.cc.

Member Data Documentation

int32_t Hypertable::MetaLog::EntityHeader::checksum {}

Checksum of serialized entity state

Definition at line 134 of file MetaLogEntityHeader.h.

bool EntityHeader::display_timestamp = true
static

Controls whether or not timestamp is printed by display()

Definition at line 149 of file MetaLogEntityHeader.h.

int32_t Hypertable::MetaLog::EntityHeader::flags {}

Flags (either FLAG_REMOVE or 0)

Definition at line 143 of file MetaLogEntityHeader.h.

int64_t Hypertable::MetaLog::EntityHeader::id {}

Unique ID of entity.

Definition at line 137 of file MetaLogEntityHeader.h.

int32_t Hypertable::MetaLog::EntityHeader::length {}

Length of entity header plus serialized state.

Definition at line 146 of file MetaLogEntityHeader.h.

std::mutex EntityHeader::ms_mutex
staticprivate

Mutex for serializing access to ms_next_id

Definition at line 157 of file MetaLogEntityHeader.h.

int64_t EntityHeader::ms_next_id = 1
staticprivate

Global counter for generating unique entity IDs

Definition at line 154 of file MetaLogEntityHeader.h.

int64_t Hypertable::MetaLog::EntityHeader::timestamp {}

Creation timestmp of entity header.

Definition at line 140 of file MetaLogEntityHeader.h.

int32_t Hypertable::MetaLog::EntityHeader::type {}

Entity type defined within the context of a Definition

Definition at line 131 of file MetaLogEntityHeader.h.


The documentation for this class was generated from the following files: