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

Commit log block header. More...

#include <BlockHeaderCommitLog.h>

Inheritance diagram for Hypertable::BlockHeaderCommitLog:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::BlockHeaderCommitLog:
Collaboration graph
[legend]

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

BlockHeaderCommitLog::BlockHeaderCommitLog ( uint16_t  version = LatestVersion)

Constructor with version number.

Initializes m_version to version and initializes all other members to their default values.

Parameters
versionVersion 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.

Parameters
magicMagic string
revisionRevision number of most recent cell in the block
cluster_idCluster ID of originating cluster

Definition at line 52 of file BlockHeaderCommitLog.cc.

Member Function Documentation

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

Decodes commit log block header from memory location.

See also
encode() for layout
Parameters
bufpAddress of pointer to beginning of serialized block header (advanced by call)
remainpAddress 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.

void BlockHeaderCommitLog::encode ( uint8_t **  bufp)
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:

EncodingDescription
int64Revision number
int16Cluster ID
Parameters
bufpAddress of pointer to destination (advanced by call)

Reimplemented from Hypertable::BlockHeader.

Definition at line 64 of file BlockHeaderCommitLog.cc.

size_t BlockHeaderCommitLog::encoded_length ( )
virtual

Returns length of serizlized block header.

See also
encode() for layout
Returns
Length of serialized 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.

Returns
true if object is logically equal to other, false otherwise.

Definition at line 93 of file BlockHeaderCommitLog.cc.

uint64_t Hypertable::BlockHeaderCommitLog::get_cluster_id ( )
inline

Gets the cluster ID field.

Returns
Cluster ID of originating cluster

Definition at line 96 of file BlockHeaderCommitLog.h.

int64_t Hypertable::BlockHeaderCommitLog::get_revision ( )
inline

Gets the revision number field.

Returns
Most recent revision number of all cells in block

Definition at line 82 of file BlockHeaderCommitLog.h.

void Hypertable::BlockHeaderCommitLog::set_cluster_id ( uint64_t  cluster_id)
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.

Parameters
cluster_idCluster ID of originating cluster

Definition at line 91 of file BlockHeaderCommitLog.h.

void Hypertable::BlockHeaderCommitLog::set_revision ( int64_t  revision)
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.

Parameters
revisionMost recent revision number of all cells in block

Definition at line 77 of file BlockHeaderCommitLog.h.

Member Data Documentation

const uint16_t BlockHeaderCommitLog::LatestVersion = 1
static

Definition at line 51 of file BlockHeaderCommitLog.h.

uint64_t Hypertable::BlockHeaderCommitLog::m_cluster_id
private

Originating cluster ID.

Definition at line 151 of file BlockHeaderCommitLog.h.

int64_t Hypertable::BlockHeaderCommitLog::m_revision
private

Revision number of the most recent cell found in the block.

Definition at line 148 of file BlockHeaderCommitLog.h.

uint16_t Hypertable::BlockHeaderCommitLog::m_version
private

Serialization format version number

Definition at line 154 of file BlockHeaderCommitLog.h.


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