Fennel: SegOutputStream Class Reference (original) (raw)

SegOutputStream implements the ByteOutputStream interface by writing data to pages allocated from a Segment. More...

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

Inheritance diagram for SegOutputStream:

List of all members.

Public Member Functions
PageId getFirstPageId () const
Gets the first PageId allocated.
BlockNum getPageCount () const
**Returns:**the number of pages allocated by this stream
void updatePage ()
Updates current page header without unlocking; allows a SegInputStream to read the contents from the same thread (but another thread would be locked out).
virtual void getSegPos (SegStreamPosition &pos)
Obtains the current stream position.
SharedSegment getSegment () const
**Returns:**segment accessed by this stream
SegmentAccessor const & getSegmentAccessor () const
**Returns:**segment accessor used by this stream
FileSize getOffset () const
**Returns:**current offset from beginning of stream
bool isClosed () const
**Returns:**whether the object has been closed
void close ()
Closes this object, releasing any unallocated resources.
void writeBytes (void const *pData, uint cbRequested)
Writes bytes to the stream.
PBuffer getWritePointer (uint cbRequested, uint *pcbActual=NULL)
Copyless alternative for writing bytes to the stream.
void consumeWritePointer (uint cbUsed)
Advances stream position after a call to getWritePointer.
void hardPageBreak ()
Marks the current buffer as complete regardless of how much data it contains.
virtual void setWriteLatency (WriteLatency writeLatency)
Changes the write latency.
template
void writeValue (T const &value)
Writes a fixed-size type to the stream.
Static Public Member Functions
static SharedSegOutputStream newSegOutputStream (SegmentAccessor const &segmentAccessor)
Creates a new SegOutputStream.
Protected Member Functions
uint getBytesWrittenThisPage () const
**Returns:**number of bytes already written to current page
virtual void flushBuffer (uint cbRequested)
Must be implemented by derived class to flush buffered data.
virtual void closeImpl ()
Must be implemented by derived class to release any resources.
SegOutputStream (SegmentAccessor const &, uint cbExtraHeader=0)
virtual void writeExtraHeaders (SegStreamNode &node)
Hook for subclasses; default is to do nothing.
void setBuffer (PBuffer pBuffer, uint cbBuffer)
Sets the current buffer to be written.
uint getBytesAvailable () const
**Returns:**number of bytes remaining to be written in current buffer
Protected Attributes
PageId firstPageId
First PageId allocated.
PageId lastPageId
Last PageId allocated.
uint cbMaxPageData
Maximum number of data bytes which can be stored per page (does not include header).
BlockNum nPagesAllocated
Counter for getPageCount().
SegmentAccessor segmentAccessor
Accessor for segment containing stream data.
SegStreamLock pageLock
Lock held on current page, if any.
uint cbPageHeader
Number of bytes in page header.
FileSize cbOffset
Byte position in stream.
bool needsClose
WriteLatency writeLatency
Current write latency mode.

Detailed Description

SegOutputStream implements the ByteOutputStream interface by writing data to pages allocated from a Segment.

The Segment must support the get/setPageSuccessor interface for chaining the pages together.

Definition at line 37 of file SegOutputStream.h.


Constructor & Destructor Documentation

SegOutputStream::SegOutputStream ( SegmentAccessor const & ,
uint cbExtraHeader = 0
) [explicit, protected]

Member Function Documentation

| uint SegOutputStream::getBytesWrittenThisPage | ( | | ) | const [protected] | | ---------------------------------------------------------------------------------------------------------- | - | | - | ------------------- |

void SegOutputStream::flushBuffer ( uint cbRequested ) [protected, virtual]

Must be implemented by derived class to flush buffered data.

Parameters:

cbRequested if non-zero, the derived class should allocate a new buffer with at least the requested size and call setBuffer

Implements ByteOutputStream.

Definition at line 75 of file SegOutputStream.cpp.

References SegNodeLock< Node >::allocatePage(), cbMaxPageData, SegStream::cbPageHeader, firstPageId, SegPageLock::getCacheAccessor(), SegNodeLock< Node >::getNodeForWrite(), SegPageLock::getPage(), SegStream::getSegment(), SegPageLock::isLocked(), lastPageId, nPagesAllocated, NULL_PAGE_ID, SegStream::pageLock, ByteOutputStream::setBuffer(), SegPageLock::unlock(), updatePage(), WRITE_EAGER_ASYNC, WRITE_LAZY, and ByteOutputStream::writeLatency.

| void SegOutputStream::closeImpl | ( | | ) | [protected, virtual] | | ------------------------------- | - | | - | ---------------------- |

void SegOutputStream::writeExtraHeaders ( SegStreamNode & node ) [protected, virtual]

| PageId SegOutputStream::getFirstPageId | ( | | ) | const | | -------------------------------------- | - | | - | ----- |

Gets the first PageId allocated.

For non-linear segments, this is required in order to be able to read the data back via SegInputStream.

Returns:

the first PageId allocated, or NULL_PAGE_ID if no data has been written to the stream yet

Definition at line 51 of file SegOutputStream.cpp.

References firstPageId.

| BlockNum SegOutputStream::getPageCount | ( | | ) | const | | ------------------------------------------------------------------------------------------ | - | | - | ----- |

| void SegOutputStream::updatePage | ( | | ) | | -------------------------------- | - | | - |

| SegmentAccessor const & SegStream::getSegmentAccessor | ( | | ) | const [inherited] | | ----------------------------------------------------------------------------------- | - | | - | ------------------- |

| FileSize ByteStream::getOffset | ( | | ) | const [inline, inherited] | | ---------------------------------------------------------------------------------- | - | | - | --------------------------- |

| bool ClosableObject::isClosed | ( | | ) | const [inline, inherited] | | ----------------------------- | - | | - | --------------------------- |

Returns:

whether the object has been closed

Definition at line 58 of file ClosableObject.h.

| void ClosableObject::close | ( | | ) | [inherited] | | -------------------------- | - | | - | ------------- |

Closes this object, releasing any unallocated resources.

Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.

Definition at line 39 of file ClosableObject.cpp.

References ClosableObject::closeImpl(), and ClosableObject::needsClose.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().

void ByteOutputStream::setBuffer ( PBuffer pBuffer,
uint cbBuffer
) [inline, protected, inherited]

| uint ByteOutputStream::getBytesAvailable | ( | | ) | const [inline, protected, inherited] | | ----------------------------------------------------------------------------------------------------- | - | | - | -------------------------------------- |

void ByteOutputStream::writeBytes ( void const * pData,
uint cbRequested
) [inherited]
PBuffer ByteOutputStream::getWritePointer ( uint cbRequested,
uint * pcbActual = NULL
) [inline, inherited]
void ByteOutputStream::consumeWritePointer ( uint cbUsed ) [inline, inherited]

| void ByteOutputStream::hardPageBreak | ( | | ) | [inherited] | | ------------------------------------ | - | | - | ------------- |

void ByteOutputStream::setWriteLatency ( WriteLatency writeLatency ) [virtual, inherited]

template

void ByteOutputStream::writeValue ( T const & value ) [inline, inherited]

Member Data Documentation

Byte position in stream.

Definition at line 41 of file ByteStream.h.

Referenced by ByteStream::ByteStream(), ByteInputStream::consumeReadPointer(), ByteOutputStream::consumeWritePointer(), ByteStream::getOffset(), getSegPos(), SegInputStream::getSegPos(), ByteInputStream::readBytes(), ByteInputStream::reset(), ByteArrayInputStream::resetArray(), ByteInputStream::seekBackward(), SegInputStream::seekSegPos(), and ByteOutputStream::writeBytes().


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


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