Fennel: SegmentFactory Class Reference (original) (raw)

SegmentFactory is a factory class for creating instances of the Segment interface. More...

#include <[SegmentFactory.h](SegmentFactory%5F8h-source.html)>

List of all members.

Public Member Functions
virtual ~SegmentFactory ()
ConfigMap const & getConfigMap () const
Returns:ConfigMap parameterizing this factory
SharedSegment newLinearDeviceSegment (SharedCache cache, LinearDeviceSegmentParams const &params)
Opens a LinearDeviceSegment.
SharedSegment newRandomAllocationSegment (SharedSegment delegateSegment, bool bFormat, bool deferInit=false)
Opens a RandomAllocationSegment.
SharedSegment newVersionedRandomAllocationSegment (SharedSegment delegateSegment, SharedSegment pTempSegment, bool bFormat, bool deferInit=false)
Opens a VersionedRandomAllocationSegment.
SharedSegment newSnapshotRandomAllocationSegment (SharedSegment delegateSegment, SharedSegment versionedSegment, TxnId snapshotCsn, bool readOnlyCommittedData=false)
Opens a new SnapshotRandomAllocationSegment.
SharedSegment newDynamicDelegatingSegment (SharedSegment delegateSegment)
Opens a new DynamicDelegatingSegment.
SharedSegment newWALSegment (SharedSegment logSegment)
Opens a WALSegment.
SharedSegment newLinearViewSegment (SharedSegment delegateSegment, PageId firstPageId)
Opens a LinearViewSegment.
SharedSegment newCircularSegment (SharedSegment delegateSegment, SharedCheckpointProvider pCheckpointProvider, PageId oldestPageId=NULL_PAGE_ID, PageId newestPageId=NULL_PAGE_ID)
Opens a CircularSegment.
SharedSegment newVersionedSegment (SharedSegment dataSegment, SharedSegment logSegment, PseudoUuid const &onlineUuid, SegVersionNum versionNumber)
Opens a VersionedSegment.
SegmentAccessor newScratchSegment (SharedCache pCache, uint nPagesMax=MAXU)
Creates a ScratchSegment.
SharedSegment newTracingSegment (SharedSegment pSegment, std::string sourceName, bool qualifySourceName=true)
If necessary, wraps a TracingSegment around another segment.
SharedSegment newTempDeviceSegment (SharedCache pCache, DeviceMode deviceMode, std::string deviceFileName)
Creates a new temporary device paired with a LinearDeviceSegment.
Static Public Member Functions
static SharedSegmentFactory newSegmentFactory (ConfigMap const &configMap, SharedTraceTarget pTraceTarget)
Constructs a new SegmentFactory.
template
static PDerivedSegment dynamicCast (SharedSegment pSegment)
Some implementations of the Segment interface extend the interface with implementation-specific features.
static SnapshotRandomAllocationSegment * getSnapshotSegment (SharedSegment pSegment)
Casts a shared segment to a SnapshotRandomAllocationSegment, if the segment is in fact a SnapshotRandomAllocationSegment.
Private Member Functions
DeviceId allocateTempDeviceId ()
void deallocateTempDeviceId (DeviceId)
SegmentFactory (ConfigMap const &configMap, SharedTraceTarget pTraceTarget)
Private Attributes
SharedTraceTarget pTraceTarget
Trace target if tracing enable.
boost::dynamic_bitset tempDeviceIdBitset
DeviceId firstTempDeviceId
StrictMutex mutex
ConfigMap configMap
Static Private Attributes
static ParamName paramTraceSegments
Friends
class TempSegDestructor

Detailed Description

SegmentFactory is a factory class for creating instances of the Segment interface.

See the design docs for more detail.

Definition at line 49 of file SegmentFactory.h.


Constructor & Destructor Documentation

| SegmentFactory::~SegmentFactory | ( | | ) | [virtual] | | -------------------------------- | - | | - | ----------- |


Member Function Documentation

| DeviceId SegmentFactory::allocateTempDeviceId | ( | | ) | [private] | | --------------------------------------------- | - | | - | ----------- |

| void SegmentFactory::deallocateTempDeviceId | ( | DeviceId | | ) | [private] | | ------------------------------------------- | - | -------- | | - | ----------- |

| ConfigMap const & SegmentFactory::getConfigMap | ( | | ) | const | | --------------------------------------------------------------------- | - | | - | ----- |

Opens a RandomAllocationSegment.

Parameters:

delegateSegment the underlying segment providing storage; this segment must return LINEAR_ALLOCATION from getAllocationOrder(), and should already be allocated to the desired size
bFormat if true, the RandomAllocationSegment is formatted as empty; otherwise, the existing formatting is read
deferInit if true, defer initialization on the segment; defaults to false

Returns:

new segment

Definition at line 87 of file SegmentFactory.cpp.

References newTracingSegment(), and NULL_PAGE_ID.

Opens a VersionedRandomAllocationSegment.

Parameters:

delegateSegment the underlying segment providing storage; this segment must return LINEAR_ALLOCATION from getAllocationOrder(), and should already be allocated to the desired size
pTempSegment the temporary segment used to store modifications to allocation node pages
bFormat if true, the VersionedRandomAllocationSegment is formatted as empty; otherwise, the existing formatting is read
deferInit if true, defer initialization on the segment; defaults to false

Returns:

new segment

Definition at line 108 of file SegmentFactory.cpp.

References newTracingSegment(), and NULL_PAGE_ID.

Opens a new SnapshotRandomAllocationSegment.

Parameters:

delegateSegment the underlying segment providing storage; most likely, this is the same as the versionedSegment
versionedSegment the underlying segment that provides versioning of pages
snapshotCsn the commit sequence number associated with the segment that determines which pages to read
readOnlyCommittedData if true, read only committed data, even ignoring uncommitted data created by the current transaction; defaults to false

Returns:

new segment

Definition at line 130 of file SegmentFactory.cpp.

References newTracingSegment().

Opens a WALSegment.

Parameters:

logSegment the Segment in which log pages are stored; this segment must guarantee at least ASCENDING_ALLOCATION (TBD: plus some other restrictions on the way in which page allocation is implemented)

Returns:

new segment

Definition at line 161 of file SegmentFactory.cpp.

References newTracingSegment().

Opens a CircularSegment.

Parameters:

delegateSegment the underlying segment
pCheckpointProvider the CheckpointProvider to call when segment space is getting low; if this is singular, the caller must take care of checkpointing to prevent space from running out
oldestPageId restored oldest PageId for recovery, or NULL_PAGE_ID for empty segment
newestPageId restored newest PageId for recovery, or NULL_PAGE_ID for empty segment or unknown

Returns:

new segment

Definition at line 215 of file SegmentFactory.cpp.

References newTracingSegment().

Opens a VersionedSegment.

Parameters:

dataSegment the segment storing the latest page versions
logSegment the log segment used for storing old page versions; an assertion violation will result if this is not an instance of WALSegment
versionNumber TODO: doc
onlineUuid TODO: doc

Returns:

new segment

Definition at line 186 of file SegmentFactory.cpp.

References newTracingSegment().

If necessary, wraps a TracingSegment around another segment.

Parameters:

pSegment the underlying segment
sourceName the trace source name for this segment
qualifySourceName if true, pSegment's pointer address is appended to sourceName to make it unique

Returns:

the wrapped segment

Definition at line 233 of file SegmentFactory.cpp.

References pTraceTarget, and TRACE_FINE.

Referenced by newCircularSegment(), newDynamicDelegatingSegment(), newLinearDeviceSegment(), newLinearViewSegment(), newRandomAllocationSegment(), newScratchSegment(), newSnapshotRandomAllocationSegment(), newTempDeviceSegment(), newVersionedRandomAllocationSegment(), newVersionedSegment(), and newWALSegment().

Creates a new temporary device paired with a LinearDeviceSegment.

The device will be automatically deleted when the segment is destroyed.

Parameters:

pCache the cache to use for this segment
deviceMode mode in which to open the device
deviceFileName filename to use for device; if relative, location is dependent on SegmentFactory configuration parameters

Returns:

new segment

Definition at line 260 of file SegmentFactory.cpp.

References allocateTempDeviceId(), DeviceMode::create, LinearDeviceSegmentParams::firstBlockId, MAXU, newTracingSegment(), LinearDeviceSegmentParams::nPagesAllocated, FileSystem::remove(), CompoundId::setBlockNum(), CompoundId::setDeviceId(), and TempSegDestructor.

template

static PDerivedSegment SegmentFactory::dynamicCast ( SharedSegment pSegment ) [inline, static]

Some implementations of the Segment interface extend the interface with implementation-specific features.

dynamicCast provides access to a derived interface from the generic SharedSegment. It is the caller's responsibility to ensure that the returned (non-shared) pointer remains protected by the original shared_ptr. All generic access to the segment should still go through the original SharedSegment for proper tracing.

Example usage given a SharedSegment pSegment:

[VersionedSegment](classVersionedSegment.html) *pVersionedSegment = SegmentFactory::dynamicCast<VersionedSegment *>(pSegment);

Parameters:

pSegment the SharedSegment to downcast

Returns:

result of the downcast as a reference, or NULL if pSegment was singular or of a different type

Definition at line 336 of file SegmentFactory.h.

References DelegatingSegment::getDelegateSegment().

00337 { 00338 PDerivedSegment pDerived = dynamic_cast( 00339 pSegment.get()); 00340 if (pDerived) { 00341 return pDerived; 00342 } 00343 TracingSegment *pTracing = dynamic_cast<TracingSegment *>( 00344 pSegment.get()); 00345 if (pTracing) { 00346 pDerived = dynamic_cast( 00347 pTracing->getDelegateSegment().get()); 00348 } 00349 return pDerived; 00350 }



Member Data Documentation


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


Generated on Mon Jun 22 04:00:45 2009 for Fennel by doxygen 1.5.1