SegStream Class Reference

SegStream is a common base for SegInputStream and SegOutputStream. More...

#include <SegStream.h>

Inheritance diagram for SegStream:

ByteStream ClosableObject SegInputStream SegOutputStream CrcSegInputStream CrcSegOutputStream List of all members.

Public Member Functions

virtual void getSegPos (SegStreamPosition &pos)=0
 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.

Protected Member Functions

virtual void closeImpl ()
 Must be implemented by derived class to release any resources.
 SegStream (SegmentAccessor const &, uint cbExtraHeader)

Protected Attributes

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

Detailed Description

SegStream is a common base for SegInputStream and SegOutputStream.

Definition at line 90 of file SegStream.h.


Constructor & Destructor Documentation

SegStream::SegStream ( SegmentAccessor const &  ,
uint  cbExtraHeader 
) [explicit, protected]

Definition at line 29 of file SegStream.cpp.

References cbPageHeader.

00031     : segmentAccessor(segmentAccessorInit),
00032       pageLock(segmentAccessor)
00033 {
00034     cbPageHeader = sizeof(SegStreamNode) + cbExtraHeader;
00035 }


Member Function Documentation

void SegStream::closeImpl (  )  [protected, virtual]

Must be implemented by derived class to release any resources.

Implements ClosableObject.

Reimplemented in SegInputStream, and SegOutputStream.

Definition at line 37 of file SegStream.cpp.

References pageLock, SegmentAccessor::reset(), segmentAccessor, and SegPageLock::unlock().

Referenced by SegOutputStream::closeImpl(), and SegInputStream::closeImpl().

00038 {
00039     pageLock.unlock();
00040     segmentAccessor.reset();
00041 }

virtual void SegStream::getSegPos ( SegStreamPosition pos  )  [pure virtual]

Obtains the current stream position.

Parameters:
pos receives the position

Implemented in SegInputStream, and SegOutputStream.

SharedSegment SegStream::getSegment (  )  const

Returns:
segment accessed by this stream

Definition at line 43 of file SegStream.cpp.

References SegmentAccessor::pSegment, and segmentAccessor.

Referenced by SegInputStream::closeImpl(), SegOutputStream::flushBuffer(), SegInputStream::readNextBuffer(), SegInputStream::readPrevBuffer(), SegInputStream::SegInputStream(), and SegOutputStream::SegOutputStream().

00044 {
00045     return segmentAccessor.pSegment;
00046 }

SegmentAccessor const & SegStream::getSegmentAccessor (  )  const

Returns:
segment accessor used by this stream

Definition at line 48 of file SegStream.cpp.

References segmentAccessor.

00049 {
00050     return segmentAccessor;
00051 }

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

Returns:
current offset from beginning of stream

Definition at line 110 of file ByteStream.h.

References ByteStream::cbOffset.

Referenced by SpillOutputStream::getInputStream(), and ByteInputStream::mark().

00111 {
00112     return cbOffset;
00113 }

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

Returns:
whether the object has been closed

Definition at line 58 of file ClosableObject.h.

00059     {
00060         return !needsClose;
00061     }

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().

00040 {
00041     if (!needsClose) {
00042         return;
00043     }
00044     needsClose = false;
00045     closeImpl();
00046 }


Member Data Documentation

SegmentAccessor SegStream::segmentAccessor [protected]

Accessor for segment containing stream data.

Definition at line 97 of file SegStream.h.

Referenced by closeImpl(), SegStreamAllocation::endWrite(), getSegment(), getSegmentAccessor(), CrcSegInputStream::lockBufferParanoid(), CrcSegInputStream::newCrcSegInputStream(), CrcSegOutputStream::newCrcSegOutputStream(), SegInputStream::newSegInputStream(), SegOutputStream::newSegOutputStream(), and SegInputStream::startPrefetch().

SegStreamLock SegStream::pageLock [protected]

Lock held on current page, if any.

Definition at line 102 of file SegStream.h.

Referenced by closeImpl(), SegInputStream::closeImpl(), SegOutputStream::flushBuffer(), SegInputStream::lockBuffer(), CrcSegInputStream::lockBuffer(), CrcSegInputStream::lockBufferParanoid(), SegInputStream::readNextBuffer(), and SegOutputStream::updatePage().

uint SegStream::cbPageHeader [protected]

Number of bytes in page header.

Definition at line 107 of file SegStream.h.

Referenced by SegOutputStream::flushBuffer(), SegInputStream::lockBuffer(), CrcSegInputStream::lockBufferParanoid(), SegOutputStream::SegOutputStream(), and SegStream().

FileSize ByteStream::cbOffset [protected, inherited]

Byte position in stream.

Definition at line 41 of file ByteStream.h.

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

bool ClosableObject::needsClose [protected, inherited]

Definition at line 44 of file ClosableObject.h.

Referenced by SegStreamAllocation::beginWrite(), ExecStreamGraphImpl::clear(), ClosableObject::ClosableObject(), ClosableObject::close(), FlatFileBuffer::open(), ExecStreamGraphImpl::open(), ExecStream::open(), and ClosableObject::~ClosableObject().


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