Zero  0.1.0
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
BlockAssembly Class Reference

Component that consumes a partially-sorted log record stream and generates indexed runs from it. More...

#include <logarchive_writer.h>

Classes

struct  BlockHeader
 

Public Member Functions

 BlockAssembly (ArchiveIndex *index, unsigned level=1, bool compression=true)
 
virtual ~BlockAssembly ()
 
bool start (run_number_t run)
 
bool add (logrec_t *lr)
 
void finish ()
 
void shutdown ()
 
bool hasPendingBlocks ()
 
void resetWriter ()
 
PageID getCurrentMaxPID ()
 

Static Public Member Functions

static run_number_t getRunFromBlock (const char *b)
 
static lsn_t getLSNFromBlock (const char *b)
 
static size_t getEndOfBlock (const char *b)
 
static PageID getMaxPIDFromBlock (const char *b)
 

Private Attributes

char * dest
 
AsyncRingBufferwritebuf
 
WriterThreadwriter
 
ArchiveIndexarchIndex
 
size_t blockSize
 
size_t pos
 
size_t fpos
 
lsn_t maxLSNInBlock
 
int maxLSNLength
 
run_number_t lastRun
 
PageID currentPID
 
size_t currentPIDpos
 
size_t currentPIDfpos
 
lsn_t currentPIDprevLSN
 
bool enableCompression
 
size_t bucketSize
 
std::vector< pair< PageID, size_t > > buckets
 
size_t nextBucket
 
unsigned level
 
PageID maxPID
 
size_t spaceToReserve
 

Detailed Description

Component that consumes a partially-sorted log record stream and generates indexed runs from it.

This class serves two purposes:

The writer thread is controlled solely using an asynchronous ring buffer. This works because the writer should keep writing as long as there are blocks available – unlike the reader thread, which must stop once a certain LSN is reached.

Each generated block contains a header, which specifies the run number, the offset up to which valid log records are found within that block, and the LSN of the last log record in the block. The run number is used by the writer thread to write blocks to the correct run file – once it changes from one block to another, it must close the currently generated run file an open a new one. The LSN in the last block header is then used to rename the file with the correct LSN range. (We used to control these LSN boundaries with an additional queue structure, but it required too many dependencies between modules that are otherwise independent)

Author
Caetano Sauer

Constructor & Destructor Documentation

§ BlockAssembly()

BlockAssembly::BlockAssembly ( ArchiveIndex index,
unsigned  level = 1,
bool  compression = true 
)

§ ~BlockAssembly()

BlockAssembly::~BlockAssembly ( )
virtual

Member Function Documentation

§ add()

bool BlockAssembly::add ( logrec_t lr)

§ finish()

void BlockAssembly::finish ( )

§ getCurrentMaxPID()

PageID BlockAssembly::getCurrentMaxPID ( )
inline

§ getEndOfBlock()

size_t BlockAssembly::getEndOfBlock ( const char *  b)
static

§ getLSNFromBlock()

lsn_t BlockAssembly::getLSNFromBlock ( const char *  b)
static

§ getMaxPIDFromBlock()

PageID BlockAssembly::getMaxPIDFromBlock ( const char *  b)
static

§ getRunFromBlock()

run_number_t BlockAssembly::getRunFromBlock ( const char *  b)
static

§ hasPendingBlocks()

bool BlockAssembly::hasPendingBlocks ( )

§ resetWriter()

void BlockAssembly::resetWriter ( )
inline

§ shutdown()

void BlockAssembly::shutdown ( )

§ start()

bool BlockAssembly::start ( run_number_t  run)

Member Data Documentation

§ archIndex

ArchiveIndex* BlockAssembly::archIndex
private

§ blockSize

size_t BlockAssembly::blockSize
private

§ buckets

std::vector<pair<PageID, size_t> > BlockAssembly::buckets
private

§ bucketSize

size_t BlockAssembly::bucketSize
private

§ currentPID

PageID BlockAssembly::currentPID
private

§ currentPIDfpos

size_t BlockAssembly::currentPIDfpos
private

§ currentPIDpos

size_t BlockAssembly::currentPIDpos
private

§ currentPIDprevLSN

lsn_t BlockAssembly::currentPIDprevLSN
private

§ dest

char* BlockAssembly::dest
private

§ enableCompression

bool BlockAssembly::enableCompression
private

§ fpos

size_t BlockAssembly::fpos
private

§ lastRun

run_number_t BlockAssembly::lastRun
private

§ level

unsigned BlockAssembly::level
private

§ maxLSNInBlock

lsn_t BlockAssembly::maxLSNInBlock
private

§ maxLSNLength

int BlockAssembly::maxLSNLength
private

§ maxPID

PageID BlockAssembly::maxPID
private

§ nextBucket

size_t BlockAssembly::nextBucket
private

§ pos

size_t BlockAssembly::pos
private

§ spaceToReserve

size_t BlockAssembly::spaceToReserve
private

§ writebuf

AsyncRingBuffer* BlockAssembly::writebuf
private

§ writer

WriterThread* BlockAssembly::writer
private

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