A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SequenceFile Class Reference

#include <SequenceFile.h>

+ Inheritance diagram for SequenceFile:
+ Collaboration diagram for SequenceFile:

Public Member Functions

 SequenceFile (NodeID nodeId, DatabaseID dbId, UserTypeID typeId, SetID setId, string path, pdb::PDBLoggerPtr logger, size_t pageSize)
 
 ~SequenceFile ()
 
bool openAll () override
 
bool closeAll () override
 
void clear () override
 
int appendPage (FilePartitionID partitionId, PDBPagePtr page) override
 
int appendPage (PDBPagePtr page)
 
int writeMeta () override
 
int updateMeta () override
 
size_t loadPage (PageID pageId, char *pageInCache, size_t length)
 
size_t loadPage (FilePartitionID partitionId, unsigned int pageSeqInPartition, char *pageInCache, size_t length) override
 
unsigned int getAndSetNumFlushedPages () override
 
unsigned int getNumFlushedPages () override
 
PageID getLastFlushedPageID () override
 
PageID getLatestPageID () override
 
size_t getPageSize () override
 
size_t getPageSizeInMeta () override
 
FileType getFileType () override
 
DatabaseID getDbId () override
 
NodeID getNodeId () override
 
SetID getSetId () override
 
UserTypeID getTypeId () override
 
string getPath ()
 
- Public Member Functions inherited from PDBFileInterface
virtual ~PDBFileInterface ()
 

Protected Member Functions

int seekPageSizeInMeta ()
 
int seekLastFlushedPageID ()
 
int seekPage (PageID pageId)
 
int writeData (void *data, size_t length)
 
int seekEnd ()
 

Private Attributes

NodeID nodeId
 
DatabaseID dbId
 
UserTypeID typeId
 
SetID setId
 
FILE * file
 
string filePath
 
PageID lastFlushedId
 
unsigned int numFlushedPages
 
size_t pageSize = 0
 
size_t metaSize
 
pdb::PDBLoggerPtr logger
 

Detailed Description

This class wraps a SequenceFile class that implements the PDBFileInterface. If using SequenceFile, each set will be flushed to a single file.

Definition at line 36 of file SequenceFile.h.

Constructor & Destructor Documentation

SequenceFile::SequenceFile ( NodeID  nodeId,
DatabaseID  dbId,
UserTypeID  typeId,
SetID  setId,
string  path,
pdb::PDBLoggerPtr  logger,
size_t  pageSize 
)

Definition at line 32 of file SequenceFile.cc.

SequenceFile::~SequenceFile ( )

Definition at line 54 of file SequenceFile.cc.

Member Function Documentation

int SequenceFile::appendPage ( FilePartitionID  partitionId,
PDBPagePtr  page 
)
overridevirtual

To append page to a file.

Implements PDBFileInterface.

Definition at line 95 of file SequenceFile.cc.

int SequenceFile::appendPage ( PDBPagePtr  page)

Definition at line 99 of file SequenceFile.cc.

void SequenceFile::clear ( )
overridevirtual

To delete a file.

Implements PDBFileInterface.

Definition at line 82 of file SequenceFile.cc.

bool SequenceFile::closeAll ( )
overridevirtual

To close a file.

Implements PDBFileInterface.

Definition at line 73 of file SequenceFile.cc.

unsigned int SequenceFile::getAndSetNumFlushedPages ( )
overridevirtual

To set and return total number of flushed pages;

Implements PDBFileInterface.

Definition at line 194 of file SequenceFile.cc.

DatabaseID SequenceFile::getDbId ( )
inlineoverridevirtual

To return DatabaseID associated with the file.

Implements PDBFileInterface.

Definition at line 91 of file SequenceFile.h.

FileType SequenceFile::getFileType ( )
inlineoverridevirtual

To return the file type of the file: SequenceFile or PartitionedFile

Implements PDBFileInterface.

Definition at line 87 of file SequenceFile.h.

PageID SequenceFile::getLastFlushedPageID ( )
overridevirtual

To return the PageID of last page flushed to the file.

Implements PDBFileInterface.

Definition at line 222 of file SequenceFile.cc.

PageID SequenceFile::getLatestPageID ( )
overridevirtual

To return the PageID of latest page.

Implements PDBFileInterface.

Definition at line 226 of file SequenceFile.cc.

NodeID SequenceFile::getNodeId ( )
inlineoverridevirtual

To return NodeID associated with the file.

Implements PDBFileInterface.

Definition at line 95 of file SequenceFile.h.

unsigned int SequenceFile::getNumFlushedPages ( )
overridevirtual

To return total number of flushed pages.

Implements PDBFileInterface.

Definition at line 218 of file SequenceFile.cc.

size_t SequenceFile::getPageSize ( )
overridevirtual

To return page size of the file

Implements PDBFileInterface.

Definition at line 162 of file SequenceFile.cc.

size_t SequenceFile::getPageSizeInMeta ( )
overridevirtual

To return page size of the file by looking into the meta data.

Implements PDBFileInterface.

Definition at line 169 of file SequenceFile.cc.

string SequenceFile::getPath ( )
inline

To return path of the file.

Definition at line 110 of file SequenceFile.h.

SetID SequenceFile::getSetId ( )
inlineoverridevirtual

To return SetID associated with the file.

Implements PDBFileInterface.

Definition at line 99 of file SequenceFile.h.

UserTypeID SequenceFile::getTypeId ( )
inlineoverridevirtual

To return UserTypeID associated with the file.

Implements PDBFileInterface.

Definition at line 103 of file SequenceFile.h.

size_t SequenceFile::loadPage ( PageID  pageId,
char *  pageInCache,
size_t  length 
)

To load data of given length on the specified page to cache. This function will be invoked by PageCache instance, length is the size of shared memory allocated for this load. The PageCache instance should make sure that length == pageSize. Otherwise, if length > pageSize, some space will be wasted, and if length < pageSize, some data on the page may not get loaded.

Definition at line 239 of file SequenceFile.cc.

size_t SequenceFile::loadPage ( FilePartitionID  partitionId,
unsigned int  pageSeqInPartition,
char *  pageInCache,
size_t  length 
)
overridevirtual

To load a page from the file partition to cache memory. Because this is the SequenceFile type, the parameter partitionId can be ignored, and pageSeqInPartition in a SequenceFile instance is always equivalent to PageID;

Implements PDBFileInterface.

Definition at line 244 of file SequenceFile.cc.

bool SequenceFile::openAll ( )
overridevirtual

To open a file.

Implements PDBFileInterface.

Definition at line 60 of file SequenceFile.cc.

int SequenceFile::seekEnd ( )
protected

Seek to the end of the file.

Definition at line 256 of file SequenceFile.cc.

int SequenceFile::seekLastFlushedPageID ( )
protected

Seek to the last flushed pageId field in meta data.

Definition at line 187 of file SequenceFile.cc.

int SequenceFile::seekPage ( PageID  pageId)
protected

Seek to the beginning of a page specified in the file.

Definition at line 230 of file SequenceFile.cc.

int SequenceFile::seekPageSizeInMeta ( )
protected

Seek to the page size field in meta data.

Definition at line 155 of file SequenceFile.cc.

int SequenceFile::updateMeta ( )
overridevirtual

To update meta data of a file

Implements PDBFileInterface.

Definition at line 151 of file SequenceFile.cc.

int SequenceFile::writeData ( void *  data,
size_t  length 
)
protected

Write data specified to the current file position.

Definition at line 119 of file SequenceFile.cc.

int SequenceFile::writeMeta ( )
overridevirtual

To initialize meta data of a file.

Implements PDBFileInterface.

Definition at line 135 of file SequenceFile.cc.

Member Data Documentation

DatabaseID SequenceFile::dbId
private

Definition at line 143 of file SequenceFile.h.

FILE* SequenceFile::file
private

Definition at line 146 of file SequenceFile.h.

string SequenceFile::filePath
private

Definition at line 147 of file SequenceFile.h.

PageID SequenceFile::lastFlushedId
private

Definition at line 148 of file SequenceFile.h.

pdb::PDBLoggerPtr SequenceFile::logger
private

Definition at line 152 of file SequenceFile.h.

size_t SequenceFile::metaSize
private

Definition at line 151 of file SequenceFile.h.

NodeID SequenceFile::nodeId
private

Definition at line 142 of file SequenceFile.h.

unsigned int SequenceFile::numFlushedPages
private

Definition at line 149 of file SequenceFile.h.

size_t SequenceFile::pageSize = 0
private

Definition at line 150 of file SequenceFile.h.

SetID SequenceFile::setId
private

Definition at line 145 of file SequenceFile.h.

UserTypeID SequenceFile::typeId
private

Definition at line 144 of file SequenceFile.h.


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