FtrsTableWriterFactory Class Reference

FtrsTableWriterFactory implements the LogicalTxnParticipantFactory interface by constructing FtrsTableWriters to be used for recovery. More...

#include <FtrsTableWriterFactory.h>

Inheritance diagram for FtrsTableWriterFactory:

LogicalTxnParticipantFactory List of all members.

Public Member Functions

 FtrsTableWriterFactory (SharedSegmentMap pSegmentMap, SharedCacheAccessor pCacheAccessor, StoredTypeDescriptorFactory const &typeFactory, SegmentAccessor scratchAccessor)
SharedFtrsTableWriter newTableWriter (FtrsTableWriterParams const &params)
virtual SharedLogicalTxnParticipant loadParticipant (LogicalTxnClassId classId, ByteInputStream &logStream)
 Recovers a LogicalTxnParticipant from the log.

Static Public Member Functions

static LogicalTxnClassId getParticipantClassId ()

Private Member Functions

void loadIndex (TupleDescriptor const &, FtrsTableIndexWriterParams &, ByteInputStream &)

Private Attributes

SharedSegmentMap pSegmentMap
SharedCacheAccessor pCacheAccessor
StoredTypeDescriptorFactory
const & 
typeFactory
std::vector< SharedFtrsTableWriterpool
SegmentAccessor scratchAccessor

Detailed Description

FtrsTableWriterFactory implements the LogicalTxnParticipantFactory interface by constructing FtrsTableWriters to be used for recovery.

It also implements online pooling, currently for a single txn at a time.

Definition at line 43 of file FtrsTableWriterFactory.h.


Constructor & Destructor Documentation

FtrsTableWriterFactory::FtrsTableWriterFactory ( SharedSegmentMap  pSegmentMap,
SharedCacheAccessor  pCacheAccessor,
StoredTypeDescriptorFactory const &  typeFactory,
SegmentAccessor  scratchAccessor 
) [explicit]

Definition at line 32 of file FtrsTableWriterFactory.cpp.

References scratchAccessor.

00037     : pSegmentMap(pSegmentMapInit),
00038       pCacheAccessor(pCacheAccessorInit),
00039       typeFactory(typeFactoryInit)
00040 {
00041     scratchAccessor = scratchAccessorInit;
00042 }


Member Function Documentation

void FtrsTableWriterFactory::loadIndex ( TupleDescriptor const &  ,
FtrsTableIndexWriterParams ,
ByteInputStream  
) [private]

Definition at line 89 of file FtrsTableWriterFactory.cpp.

References BTreeInsertExecStreamParams::distinctness, FtrsTableIndexWriterParams::inputProj, BTreeParams::keyProj, BTreeParams::pageOwnerId, pCacheAccessor, ExecStreamParams::pCacheAccessor, TupleDescriptor::projectFrom(), BTreeParams::pSegment, pSegmentMap, TupleProjection::readPersistent(), ByteInputStream::readValue(), BTreeParams::rootPageId, scratchAccessor, ExecStreamParams::scratchAccessor, BTreeParams::segmentId, BTreeParams::tupleDesc, and FtrsTableIndexWriterParams::updateInPlace.

Referenced by loadParticipant().

00093 {
00094     logStream.readValue(params.segmentId);
00095     logStream.readValue(params.pageOwnerId);
00096     logStream.readValue(params.rootPageId);
00097     logStream.readValue(params.distinctness);
00098     logStream.readValue(params.updateInPlace);
00099     params.inputProj.readPersistent(logStream);
00100     params.keyProj.readPersistent(logStream);
00101     if (params.inputProj.empty()) {
00102         params.tupleDesc = clusteredTupleDesc;
00103     } else {
00104         params.tupleDesc.projectFrom(clusteredTupleDesc,params.inputProj);
00105     }
00106     params.pCacheAccessor = pCacheAccessor;
00107     SharedSegment pSegment;
00108     params.pSegment = pSegmentMap->getSegmentById(params.segmentId, pSegment);
00109     params.scratchAccessor = scratchAccessor;
00110 }

SharedFtrsTableWriter FtrsTableWriterFactory::newTableWriter ( FtrsTableWriterParams const &  params  ) 

Definition at line 44 of file FtrsTableWriterFactory.cpp.

References pool, FtrsTableWriterParams::tableId, and FtrsTableWriterParams::updateProj.

00046 {
00047     // check pool first
00048     for (uint i = 0; i < pool.size(); ++i) {
00049         SharedFtrsTableWriter pPooledWriter = pool[i];
00050         if (pPooledWriter->getTableId() != params.tableId) {
00051             continue;
00052         }
00053         if (pPooledWriter->updateProj != params.updateProj) {
00054             continue;
00055         }
00056         // TODO:  assert that other parameters match?
00057         return pPooledWriter;
00058     }
00059     SharedFtrsTableWriter pNewWriter(new FtrsTableWriter(params));
00060     pool.push_back(pNewWriter);
00061     return pNewWriter;
00062 }

SharedLogicalTxnParticipant FtrsTableWriterFactory::loadParticipant ( LogicalTxnClassId  classId,
ByteInputStream logStream 
) [virtual]

Recovers a LogicalTxnParticipant from the log.

Using the classId to determine the participant type to create, the factory reads required constructor parameters from the log input stream. The factory may peool participant instances; i.e. when the same constructor parameters are encountered a second time, the factory can return the same instance. (TODO: refine this when parallelized recovery is implemented.) The implementation must consume ALL log data for this record, even if some of it turns out to be unneeded.

Parameters:
classId the LogicalTxnClassId recorded when the participant was logged while online
logStream the log information written by the participant's describeParticipant() implementation
Returns:
reference to loaded participant

Implements LogicalTxnParticipantFactory.

Definition at line 64 of file FtrsTableWriterFactory.cpp.

References getParticipantClassId(), FtrsTableWriterParams::indexParams, loadIndex(), TupleProjection::readPersistent(), TupleDescriptor::readPersistent(), ByteInputStream::readValue(), typeFactory, and FtrsTableWriterParams::updateProj.

00067 {
00068     assert(classId == getParticipantClassId());
00069 
00070     TupleDescriptor clusteredTupleDesc;
00071     clusteredTupleDesc.readPersistent(logStream,typeFactory);
00072 
00073     uint nIndexes;
00074     logStream.readValue(nIndexes);
00075 
00076     FtrsTableWriterParams params;
00077     params.indexParams.resize(nIndexes);
00078 
00079     for (uint i = 0; i < nIndexes; ++i) {
00080         loadIndex(clusteredTupleDesc,params.indexParams[i],logStream);
00081     }
00082 
00083     params.updateProj.readPersistent(logStream);
00084 
00085     return SharedLogicalTxnParticipant(
00086         new FtrsTableWriter(params));
00087 }

LogicalTxnClassId FtrsTableWriterFactory::getParticipantClassId (  )  [static]

Definition at line 112 of file FtrsTableWriterFactory.cpp.

Referenced by FtrsTableWriter::getParticipantClassId(), and loadParticipant().

00113 {
00114     return LogicalTxnClassId(0xaa6576b8efadbcdcLL);
00115 }


Member Data Documentation

SharedSegmentMap FtrsTableWriterFactory::pSegmentMap [private]

Definition at line 46 of file FtrsTableWriterFactory.h.

Referenced by loadIndex().

SharedCacheAccessor FtrsTableWriterFactory::pCacheAccessor [private]

Definition at line 47 of file FtrsTableWriterFactory.h.

Referenced by loadIndex().

StoredTypeDescriptorFactory const& FtrsTableWriterFactory::typeFactory [private]

Definition at line 48 of file FtrsTableWriterFactory.h.

Referenced by loadParticipant().

std::vector<SharedFtrsTableWriter> FtrsTableWriterFactory::pool [private]

Definition at line 49 of file FtrsTableWriterFactory.h.

Referenced by newTableWriter().

SegmentAccessor FtrsTableWriterFactory::scratchAccessor [private]

Definition at line 50 of file FtrsTableWriterFactory.h.

Referenced by FtrsTableWriterFactory(), and loadIndex().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:32 2009 for Fennel by  doxygen 1.5.1