BTreeRecoveryFactory Class Reference

BTreeRecoveryFactory implements the LogicalTxnParticipantFactory interface by constructing BTreeWriters to be used for recovery. More...

#include <BTreeRecoveryFactory.h>

Inheritance diagram for BTreeRecoveryFactory:

LogicalTxnParticipantFactory List of all members.

Public Member Functions

 BTreeRecoveryFactory (SegmentAccessor segmentAccessor, SegmentAccessor scratchAccessor, StoredTypeDescriptorFactory const &typeFactory)
virtual SharedLogicalTxnParticipant loadParticipant (LogicalTxnClassId classId, ByteInputStream &logStream)
 Recovers a LogicalTxnParticipant from the log.

Static Public Member Functions

static LogicalTxnClassId getParticipantClassId ()

Private Attributes

SegmentAccessor segmentAccessor
SegmentAccessor scratchAccessor
const & 
std::hash_map< PageId, SharedLogicalTxnParticipantwriterMap

Detailed Description

BTreeRecoveryFactory implements the LogicalTxnParticipantFactory interface by constructing BTreeWriters to be used for recovery.

Definition at line 41 of file BTreeRecoveryFactory.h.

Constructor & Destructor Documentation

BTreeRecoveryFactory::BTreeRecoveryFactory ( SegmentAccessor  segmentAccessor,
SegmentAccessor  scratchAccessor,
StoredTypeDescriptorFactory const &  typeFactory 
) [explicit]

Definition at line 32 of file BTreeRecoveryFactory.cpp.

00036     : segmentAccessor(segmentAccessortInit),
00037       scratchAccessor(scratchAccessortInit),
00038       typeFactory(typeFactoryInit)
00039 {
00040 }

Member Function Documentation

SharedLogicalTxnParticipant BTreeRecoveryFactory::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.

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

Implements LogicalTxnParticipantFactory.

Definition at line 42 of file BTreeRecoveryFactory.cpp.

References getParticipantClassId(), BTreeDescriptor::keyProjection, TupleProjection::readPersistent(), TupleDescriptor::readPersistent(), ByteInputStream::readValue(), BTreeDescriptor::rootPageId, scratchAccessor, segmentAccessor, BTreeDescriptor::segmentAccessor, BTreeDescriptor::tupleDescriptor, typeFactory, and writerMap.

00045 {
00046     assert(classId == getParticipantClassId());
00047     BTreeDescriptor descriptor;
00048     logStream.readValue(descriptor.rootPageId);
00049     descriptor.segmentAccessor = segmentAccessor;
00050     descriptor.tupleDescriptor.readPersistent(logStream,typeFactory);
00051     descriptor.keyProjection.readPersistent(logStream);
00053     SharedLogicalTxnParticipant pParticipant = writerMap[descriptor.rootPageId];
00054     if (pParticipant) {
00055         return pParticipant;
00056     }
00058     pParticipant = SharedBTreeWriter(
00059         new BTreeWriter(
00060             descriptor,scratchAccessor));
00062     writerMap[descriptor.rootPageId] = pParticipant;
00064     return pParticipant;
00065 }

LogicalTxnClassId BTreeRecoveryFactory::getParticipantClassId (  )  [static]

Definition at line 67 of file BTreeRecoveryFactory.cpp.

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

00068 {
00069     return LogicalTxnClassId(0x80890de8a406fdedLL);
00070 }

Member Data Documentation

SegmentAccessor BTreeRecoveryFactory::segmentAccessor [private]

Definition at line 44 of file BTreeRecoveryFactory.h.

Referenced by loadParticipant().

SegmentAccessor BTreeRecoveryFactory::scratchAccessor [private]

Definition at line 45 of file BTreeRecoveryFactory.h.

Referenced by loadParticipant().

StoredTypeDescriptorFactory const& BTreeRecoveryFactory::typeFactory [private]

Definition at line 46 of file BTreeRecoveryFactory.h.

Referenced by loadParticipant().

std::hash_map<PageId,SharedLogicalTxnParticipant> BTreeRecoveryFactory::writerMap [private]

Definition at line 48 of file BTreeRecoveryFactory.h.

Referenced by loadParticipant().

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