Commit log block header. More...
#include <BlockHeaderCommitLog.h>
Public Member Functions | |
BlockHeaderCommitLog (uint16_t version=LatestVersion) | |
Constructor with version number. More... | |
BlockHeaderCommitLog (const char *magic, int64_t revision, uint64_t cluster_id) | |
Constructor with member initializers. More... | |
void | set_revision (int64_t revision) |
Sets the revision number field. More... | |
int64_t | get_revision () |
Gets the revision number field. More... | |
void | set_cluster_id (uint64_t cluster_id) |
Sets the cluster ID field. More... | |
uint64_t | get_cluster_id () |
Gets the cluster ID field. More... | |
virtual size_t | encoded_length () |
Returns length of serizlized block header. More... | |
virtual void | encode (uint8_t **bufp) |
Encodes commit log block header to memory location. More... | |
virtual void | decode (const uint8_t **bufp, size_t *remainp) |
Decodes commit log block header from memory location. More... | |
bool | equals (const BlockHeaderCommitLog &other) const |
Equality test. More... | |
Public Member Functions inherited from Hypertable::BlockHeader | |
BlockHeader (uint16_t version=LatestVersion, const char *magic=0) | |
Constructor. More... | |
virtual | ~BlockHeader () |
Destructor. More... | |
void | set_magic (const char *magic) |
Sets the "magic" field. More... | |
const char * | get_magic () |
Gets a pointer to the "magic" field. More... | |
bool | check_magic (const char *magic) |
Compares a given character sequence with the magic field. More... | |
void | set_data_length (uint32_t length) |
Sets the uncompressed data length field. More... | |
uint32_t | get_data_length () |
Gets the uncompressed data length field. More... | |
void | set_data_zlength (uint32_t zlength) |
Sets the compressed data length field. More... | |
uint32_t | get_data_zlength () |
Gets the compressed data length field. More... | |
void | set_data_checksum (uint32_t checksum) |
Sets the checksum field. More... | |
uint32_t | get_data_checksum () |
Gets the checksum field. More... | |
void | set_compression_type (uint16_t type) |
Sets the compression type field. More... | |
uint16_t | get_compression_type () |
Gets the compression type field. More... | |
void | set_flags (uint16_t flags) |
Sets the flags field. More... | |
uint16_t | get_flags () |
Gets the flags field. More... | |
void | write_header_checksum (uint8_t *base) |
Computes and writes checksum field. More... | |
bool | equals (const BlockHeader &other) const |
Equality test. More... | |
Static Public Attributes | |
static const uint16_t | LatestVersion = 1 |
Static Public Attributes inherited from Hypertable::BlockHeader | |
static const uint16_t | LatestVersion = 1 |
Private Attributes | |
int64_t | m_revision |
Revision number of the most recent cell found in the block. More... | |
uint64_t | m_cluster_id |
Originating cluster ID. More... | |
uint16_t | m_version |
Serialization format version number More... | |
Additional Inherited Members | |
Protected Attributes inherited from Hypertable::BlockHeader | |
char | m_magic [10] |
"Magic" string used to identify start of block header More... | |
uint16_t | m_flags |
Flags. More... | |
uint32_t | m_data_length |
Uncompressed length of the data stored within the block. More... | |
uint32_t | m_data_zlength |
Compressed length of the data stored within the block. More... | |
uint32_t | m_data_checksum |
Checksum of (possibly compressed) data stored within the block. More... | |
uint16_t | m_compression_type |
Type of data compression used (see BlockCompressionCodec::Type) More... | |
Commit log block header.
This class represents a commit log block header in memory and provides methods for encoding and decoding the header to and from disk.
Definition at line 47 of file BlockHeaderCommitLog.h.
BlockHeaderCommitLog::BlockHeaderCommitLog | ( | uint16_t | version = LatestVersion | ) |
Constructor with version number.
Initializes m_version to version
and initializes all other members to their default values.
version | Version of commit log block header |
Definition at line 46 of file BlockHeaderCommitLog.cc.
BlockHeaderCommitLog::BlockHeaderCommitLog | ( | const char * | magic, |
int64_t | revision, | ||
uint64_t | cluster_id | ||
) |
Constructor with member initializers.
Initializes base class BlockHeader, and sets m_revision to revision
, and m_cluster_id to cluster_id
.
magic | Magic string |
revision | Revision number of most recent cell in the block |
cluster_id | Cluster ID of originating cluster |
Definition at line 52 of file BlockHeaderCommitLog.cc.
|
virtual |
Decodes commit log block header from memory location.
bufp | Address of pointer to beginning of serialized block header (advanced by call) |
remainp | Address of variable holding remaining valid data pointed to by bufp (decremented by call) |
Reimplemented from Hypertable::BlockHeader.
Definition at line 76 of file BlockHeaderCommitLog.cc.
|
virtual |
Encodes commit log block header to memory location.
This method writes a serailized representation of the header to the memory location pointed to by *bufp
. It first encodes the base portion of the header with a call to BlockHeader::encode() and then writes the commit log specific fields (m_revision and m_cluster_id). It then calls BlockHeader::write_header_checksum() to compute and store the checksum. At the end of the call, *bufp
will point to the memory location immediately following the serialized header. The encoding of the commit log specific fields has the following format:
Encoding | Description |
---|---|
int64 | Revision number |
int16 | Cluster ID |
bufp | Address of pointer to destination (advanced by call) |
Reimplemented from Hypertable::BlockHeader.
Definition at line 64 of file BlockHeaderCommitLog.cc.
|
virtual |
Returns length of serizlized block header.
Reimplemented from Hypertable::BlockHeader.
Definition at line 59 of file BlockHeaderCommitLog.cc.
bool BlockHeaderCommitLog::equals | ( | const BlockHeaderCommitLog & | other | ) | const |
Equality test.
This method compares the members of the object to the members of other
, returning true if they're all equal.
other
, false otherwise. Definition at line 93 of file BlockHeaderCommitLog.cc.
|
inline |
Gets the cluster ID field.
Definition at line 96 of file BlockHeaderCommitLog.h.
|
inline |
Gets the revision number field.
Definition at line 82 of file BlockHeaderCommitLog.h.
|
inline |
Sets the cluster ID field.
Each block of updates that get written to a database cluster has an associated cluster ID. The cluster ID indicates into which database cluster the data was originally inserted, and is used by the inter- datacenter replication logic to prevent duplicate replication of data.
cluster_id | Cluster ID of originating cluster |
Definition at line 91 of file BlockHeaderCommitLog.h.
|
inline |
Sets the revision number field.
Each commit log block stores a sequence of cells, each containing a revision number. The revision number in the commit log block header is the most recent (largest) revision number of all of the cells stored in the block.
revision | Most recent revision number of all cells in block |
Definition at line 77 of file BlockHeaderCommitLog.h.
|
static |
Definition at line 51 of file BlockHeaderCommitLog.h.
|
private |
Originating cluster ID.
Definition at line 151 of file BlockHeaderCommitLog.h.
|
private |
Revision number of the most recent cell found in the block.
Definition at line 148 of file BlockHeaderCommitLog.h.
|
private |
Serialization format version number
Definition at line 154 of file BlockHeaderCommitLog.h.