SegInputStream Class Reference

SegInputStream implements the ByteInputStream interface by reading data previously written via a SegOutputStream. More...

#include <SegInputStream.h>

Inheritance diagram for SegInputStream:

SegStream ByteInputStream ByteStream ByteStream ClosableObject ClosableObject CrcSegInputStream List of all members.

Public Member Functions

void startPrefetch ()
 Requests that prefetch be performed in anticipation of forward scan.
void endPrefetch ()
 Disables prefetch.
void setDeallocate (bool shouldDeallocate)
 Requests that pages be deallocated after the stream is done reading them.
bool isDeallocating ()
 
Returns:
true if currently set to deallocate pages as they are read

virtual void getSegPos (SegStreamPosition &pos)
 Obtains the current stream position.
void seekSegPos (SegStreamPosition const &pos)
 Seeks to a previously recorded stream position.
virtual SharedByteStreamMarker newMarker ()
 Creates a new uninitialized marker for this stream.
virtual void mark (ByteStreamMarker &marker)
 Marks the current stream position in preparation for a future call to reset().
virtual void reset (ByteStreamMarker const &marker)
 Resets stream to a previously marked 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.
uint readBytes (void *pData, uint cbRequested)
 Reads bytes from the stream.
template<class T>
uint readValue (T &value)
 Reads a fixed-size value from the stream.
PConstBuffer getReadPointer (uint cbRequested, uint *pcbActual=NULL)
 Copyless alternative for reading bytes from the stream.
void consumeReadPointer (uint cbUsed)
 Advances stream position after a call to getReadPointer.
void seekForward (uint cb)
 Skips forward in stream.
void seekBackward (uint cb)
 Skips backward in stream.

Static Public Member Functions

static SharedSegInputStream newSegInputStream (SegmentAccessor const &segmentAccessor, PageId beginPageId=FIRST_LINEAR_PAGE_ID)
 Creates a new SegInputStream, positioned at beginning-of-stream.

Protected Member Functions

virtual void readNextBuffer ()
 Must be implemented by derived class by calling either setBuffer or nullifyBuffer.
virtual void readPrevBuffer ()
 Must be implemented by derived class if seekBackward is to be supported.
virtual void closeImpl ()
 Must be implemented by derived class to release any resources.
 SegInputStream (SegmentAccessor const &, PageId, uint cbExtraHeader=0)
virtual void lockBuffer ()
void setBuffer (PConstBuffer pBuffer, uint cbBuffer)
 Sets the current buffer to be read.
void nullifyBuffer ()
 Nullifies the current buffer, indicating no more data is available.
uint getBytesAvailable () const
 
Returns:
number of bytes remaining in current buffer

uint getBytesConsumed () const
 
Returns:
number of bytes already consumed from current buffer


Protected Attributes

SegPageIter pageIter
PageId currPageId
 PageId of current page.
bool shouldDeallocate
 Whether to deallocate stream pages when no longer needed.
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

SegInputStream implements the ByteInputStream interface by reading data previously written via a SegOutputStream.

seekBackward is supported, but only if the underlying segment supports CONSECUTIVE_ALLOCATION or LINEAR_ALLOCATION.

Definition at line 39 of file SegInputStream.h.


Constructor & Destructor Documentation

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

Definition at line 38 of file SegInputStream.cpp.

References currPageId, FIRST_LINEAR_PAGE_ID, SegStream::getSegment(), Segment::LINEAR_ALLOCATION, and shouldDeallocate.

Referenced by newSegInputStream().

00042     : SegStream(segmentAccessor,cbExtraHeader)
00043 {
00044     if (beginPageId == FIRST_LINEAR_PAGE_ID) {
00045         assert(
00046             getSegment()->getAllocationOrder() == Segment::LINEAR_ALLOCATION);
00047     }
00048     currPageId = beginPageId;
00049     shouldDeallocate = false;
00050 }


Member Function Documentation

void SegInputStream::readNextBuffer (  )  [protected, virtual]

Must be implemented by derived class by calling either setBuffer or nullifyBuffer.

Implements ByteInputStream.

Definition at line 71 of file SegInputStream.cpp.

References currPageId, SegPageLock::deallocateLockedPage(), SegStream::getSegment(), SegPageLock::isLocked(), SegPageIter::isSingular(), lockBuffer(), NULL_PAGE_ID, ByteInputStream::nullifyBuffer(), pageIter, SegStream::pageLock, shouldDeallocate, and SegPageLock::unlock().

00072 {
00073     nullifyBuffer();
00074     if (pageLock.isLocked()) {
00075         if (currPageId != NULL_PAGE_ID) {
00076             if (pageIter.isSingular()) {
00077                 currPageId = getSegment()->getPageSuccessor(currPageId);
00078             } else {
00079                 ++pageIter;
00080                 assert(*pageIter == getSegment()->getPageSuccessor(currPageId));
00081                 currPageId = *pageIter;
00082             }
00083         }
00084         if (shouldDeallocate) {
00085             pageLock.deallocateLockedPage();
00086         } else {
00087             pageLock.unlock();
00088         }
00089     }
00090     if (currPageId == NULL_PAGE_ID) {
00091         return;
00092     }
00093     lockBuffer();
00094 }

void SegInputStream::readPrevBuffer (  )  [protected, virtual]

Must be implemented by derived class if seekBackward is to be supported.

Reimplemented from ByteInputStream.

Definition at line 96 of file SegInputStream.cpp.

References Segment::CONSECUTIVE_ALLOCATION, currPageId, Segment::getLinearBlockNum(), SegStream::getSegment(), SegPageIter::isSingular(), lockBuffer(), ByteInputStream::nullifyBuffer(), and pageIter.

00097 {
00098     assert(pageIter.isSingular());
00099     assert(
00100         getSegment()->getAllocationOrder() >= Segment::CONSECUTIVE_ALLOCATION);
00101     nullifyBuffer();
00102     if (Segment::getLinearBlockNum(currPageId) == 0) {
00103         return;
00104     }
00105     --currPageId;
00106     lockBuffer();
00107 }

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

Must be implemented by derived class to release any resources.

Reimplemented from SegStream.

Definition at line 109 of file SegInputStream.cpp.

References SegStream::closeImpl(), currPageId, SegPageLock::deallocateUnlockedPage(), SegStream::getSegment(), SegPageIter::makeSingular(), NULL_PAGE_ID, pageIter, SegStream::pageLock, shouldDeallocate, and SegPageLock::unlock().

00110 {
00111     pageIter.makeSingular();
00112     if (shouldDeallocate) {
00113         pageLock.unlock();
00114         while (currPageId != NULL_PAGE_ID) {
00115             PageId nextPageId = getSegment()->getPageSuccessor(currPageId);
00116             pageLock.deallocateUnlockedPage(currPageId);
00117             currPageId = nextPageId;
00118         }
00119     }
00120     SegStream::closeImpl();
00121 }

void SegInputStream::lockBuffer (  )  [protected, virtual]

Reimplemented in CrcSegInputStream.

Definition at line 62 of file SegInputStream.cpp.

References SegStreamNode::cbData, SegStream::cbPageHeader, currPageId, SegNodeLock< Node >::getNodeForRead(), SegPageLock::lockShared(), SegStream::pageLock, ByteInputStream::pFirstByte, and ByteInputStream::setBuffer().

Referenced by readNextBuffer(), readPrevBuffer(), and seekSegPos().

00063 {
00064     pageLock.lockShared(currPageId);
00065     SegStreamNode const &node = pageLock.getNodeForRead();
00066     PConstBuffer pFirstByte =
00067         reinterpret_cast<PConstBuffer>(&node) + cbPageHeader;
00068     setBuffer(pFirstByte,node.cbData);
00069 }

SharedSegInputStream SegInputStream::newSegInputStream ( SegmentAccessor const &  segmentAccessor,
PageId  beginPageId = FIRST_LINEAR_PAGE_ID 
) [static]

Creates a new SegInputStream, positioned at beginning-of-stream.

Parameters:
segmentAccessor accessor for the segment containing the stream data
beginPageId the first page of stream data; if the default FIRST_LINEAR_PAGE_ID is passed, the segment must support LINEAR_ALLOCATION, and the stream starts at the first page of the segment; if NULL_PAGE_ID is passed, an empty stream is returned
Returns:
shared_ptr to new SegInputStream

Definition at line 29 of file SegInputStream.cpp.

References SegInputStream(), and SegStream::segmentAccessor.

Referenced by SegBufferWriter::closeImpl(), SegStreamAllocation::endWrite(), SpillOutputStream::getInputStream(), VariableBuildLevel::getParentKeyStream(), SegBufferReader::open(), LogicalRecoveryLog::openLongLogStream(), BTreeTest::testBulkLoad(), SegStreamTest::testMarkReset(), BTreeReadersTest::testReaders(), and SegStreamTest::testReadSeg().

00032 {
00033     return SharedSegInputStream(
00034         new SegInputStream(segmentAccessor,beginPageId),
00035         ClosableObjectDestructor());
00036 }

void SegInputStream::startPrefetch (  ) 

Requests that prefetch be performed in anticipation of forward scan.

Definition at line 52 of file SegInputStream.cpp.

References currPageId, SegPageIter::mapRange(), pageIter, and SegStream::segmentAccessor.

Referenced by reset().

00053 {
00054     pageIter.mapRange(segmentAccessor,currPageId);
00055 }

void SegInputStream::endPrefetch (  ) 

Disables prefetch.

Definition at line 57 of file SegInputStream.cpp.

References SegPageIter::makeSingular(), and pageIter.

Referenced by reset().

00058 {
00059     pageIter.makeSingular();
00060 }

void SegInputStream::setDeallocate ( bool  shouldDeallocate  ) 

Requests that pages be deallocated after the stream is done reading them.

If in effect, any unread pages will also be deallocated when the stream is closed. Note that usage of deallocation may cause other methods such as seekSegPos and seekBackward to fail.

Parameters:
shouldDeallocate whether to deallocate pages

Definition at line 145 of file SegInputStream.cpp.

References shouldDeallocate.

00147 {
00148     shouldDeallocate = shouldDeallocateInit;
00149 }

bool SegInputStream::isDeallocating (  ) 

Returns:
true if currently set to deallocate pages as they are read

Definition at line 151 of file SegInputStream.cpp.

References shouldDeallocate.

00152 {
00153     return shouldDeallocate;
00154 }

void SegInputStream::getSegPos ( SegStreamPosition pos  )  [virtual]

Obtains the current stream position.

Parameters:
pos receives the position

Implements SegStream.

Definition at line 123 of file SegInputStream.cpp.

References ByteStream::cbOffset, SegStreamPosition::cbOffset, currPageId, ByteInputStream::getBytesConsumed(), SegStreamPosition::segByteId, CompoundId::setByteOffset(), and CompoundId::setPageId().

Referenced by mark().

void SegInputStream::seekSegPos ( SegStreamPosition const &  pos  ) 

Seeks to a previously recorded stream position.

Parameters:
pos the new position, previously returned by getSegPos

Definition at line 130 of file SegInputStream.cpp.

References SegStreamPosition::cbOffset, ByteStream::cbOffset, ByteInputStream::consumeReadPointer(), currPageId, CompoundId::getByteOffset(), ByteInputStream::getBytesAvailable(), CompoundId::getPageId(), SegPageIter::isSingular(), lockBuffer(), CompoundId::MAX_BYTE_OFFSET, pageIter, and SegStreamPosition::segByteId.

Referenced by reset().

00131 {
00132     assert(pageIter.isSingular());
00133     currPageId = CompoundId::getPageId(pos.segByteId);
00134     lockBuffer();
00135     uint cb = CompoundId::getByteOffset(pos.segByteId);
00136     if (cb == CompoundId::MAX_BYTE_OFFSET) {
00137         consumeReadPointer(getBytesAvailable());
00138     } else {
00139         consumeReadPointer(cb);
00140     }
00141 
00142     cbOffset = pos.cbOffset;
00143 }

SharedByteStreamMarker SegInputStream::newMarker (  )  [virtual]

Creates a new uninitialized marker for this stream.

The returned marker must be passed to mark() in order to initialize it.

Returns:
shared pointer to new marker

Reimplemented from ByteInputStream.

Definition at line 156 of file SegInputStream.cpp.

00157 {
00158     return SharedByteStreamMarker(new SegStreamMarker(*this));
00159 }

void SegInputStream::mark ( ByteStreamMarker marker  )  [virtual]

Marks the current stream position in preparation for a future call to reset().

How long this marker remains valid depends upon the implementation of the ByteInputStream.

Parameters:
marker memento object created with newMarker() on the same stream; receives the marked position (forgetting any previously marked position)

Reimplemented from ByteInputStream.

Definition at line 161 of file SegInputStream.cpp.

References getSegPos(), ByteStreamMarker::getStream(), and SegStreamMarker::segPos.

00162 {
00163     assert(&(marker.getStream()) == this);
00164 
00165     // memorize SegStream-specific info
00166     SegStreamMarker &segMarker =
00167         dynamic_cast<SegStreamMarker &>(marker);
00168     getSegPos(segMarker.segPos);
00169 }

void SegInputStream::reset ( ByteStreamMarker const &  marker  )  [virtual]

Resets stream to a previously marked position.

The base implementation uses seekForward/seekBackward (i.e. sequential access), making it inefficient for large streams. Derived classes may override with more efficient implementations such as random access.

Parameters:
marker memento previously memorized with mark()

Reimplemented from ByteInputStream.

Definition at line 171 of file SegInputStream.cpp.

References endPrefetch(), ByteStreamMarker::getStream(), SegPageIter::isSingular(), pageIter, seekSegPos(), SegStreamMarker::segPos, and startPrefetch().

00172 {
00173     assert(&(marker.getStream()) == this);
00174 
00175     // use SegStream-specific info
00176     SegStreamMarker const &segMarker =
00177         dynamic_cast<SegStreamMarker const &>(marker);
00178 
00179     // disable prefetch during seek
00180     bool prefetch = !pageIter.isSingular();
00181     endPrefetch();
00182 
00183     seekSegPos(segMarker.segPos);
00184 
00185     // restore prefetch preference
00186     if (prefetch) {
00187         startPrefetch();
00188     }
00189 }

SharedSegment SegStream::getSegment (  )  const [inherited]

Returns:
segment accessed by this stream

Definition at line 43 of file SegStream.cpp.

References SegmentAccessor::pSegment, and SegStream::segmentAccessor.

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

00044 {
00045     return segmentAccessor.pSegment;
00046 }

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

Returns:
segment accessor used by this stream

Definition at line 48 of file SegStream.cpp.

References SegStream::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 }

void ByteInputStream::setBuffer ( PConstBuffer  pBuffer,
uint  cbBuffer 
) [inline, protected, inherited]

Sets the current buffer to be read.

Parameters:
pBuffer receives start address of new buffer
cbBuffer number of bytes in buffer

Definition at line 241 of file ByteInputStream.h.

References ByteInputStream::pEndByte, ByteInputStream::pFirstByte, and ByteInputStream::pNextByte.

Referenced by ByteArrayInputStream::ByteArrayInputStream(), lockBuffer(), CrcSegInputStream::lockBufferParanoid(), ByteInputStream::nullifyBuffer(), and ByteArrayInputStream::resetArray().

00244 {
00245     pFirstByte = pBuffer;
00246     pEndByte = pBuffer + cbBuffer;
00247     pNextByte = pFirstByte;
00248 }

void ByteInputStream::nullifyBuffer (  )  [inline, protected, inherited]

Nullifies the current buffer, indicating no more data is available.

Definition at line 250 of file ByteInputStream.h.

References ByteInputStream::setBuffer().

Referenced by ByteInputStream::ByteInputStream(), CrcSegInputStream::lockBuffer(), readNextBuffer(), ByteArrayInputStream::readNextBuffer(), readPrevBuffer(), and ByteArrayInputStream::readPrevBuffer().

00251 {
00252     setBuffer(NULL,0);
00253 }

uint ByteInputStream::getBytesAvailable (  )  const [inline, protected, inherited]

Returns:
number of bytes remaining in current buffer

Definition at line 199 of file ByteInputStream.h.

References ByteInputStream::pEndByte, and ByteInputStream::pNextByte.

Referenced by ByteInputStream::consumeReadPointer(), ByteInputStream::getReadPointer(), ByteInputStream::readBytes(), and seekSegPos().

00200 {
00201     return static_cast<uint>(pEndByte - pNextByte);
00202 }

uint ByteInputStream::getBytesConsumed (  )  const [inline, protected, inherited]

Returns:
number of bytes already consumed from current buffer

Definition at line 204 of file ByteInputStream.h.

References ByteInputStream::pFirstByte, and ByteInputStream::pNextByte.

Referenced by getSegPos(), and ByteInputStream::seekBackward().

00205 {
00206     return static_cast<uint>(pNextByte - pFirstByte);
00207 }

uint ByteInputStream::readBytes ( void *  pData,
uint  cbRequested 
) [inherited]

Reads bytes from the stream.

Parameters:
pData target buffer to read into
cbRequested number of bytes to read
Returns:
number of bytes actually read; 0 indicates end-of-stream

Definition at line 34 of file ByteInputStream.cpp.

References ByteStream::cbOffset, ByteInputStream::getBytesAvailable(), ByteInputStream::pEndByte, ByteInputStream::pNextByte, and ByteInputStream::readNextBuffer().

Referenced by FtrsTableWriter::redoLogicalAction(), and ByteInputStream::seekForward().

00036 {
00037     uint cbActual = 0;
00038     if (pNextByte == pEndByte) {
00039         readNextBuffer();
00040     }
00041     for (;;) {
00042         uint cbAvailable = getBytesAvailable();
00043         if (!cbAvailable) {
00044             break;
00045         }
00046         if (cbRequested <= cbAvailable) {
00047             if (pData) {
00048                 memcpy(pData,pNextByte,cbRequested);
00049             }
00050             pNextByte += cbRequested;
00051             cbActual += cbRequested;
00052             break;
00053         }
00054         if (pData) {
00055             memcpy(pData,pNextByte,cbAvailable);
00056             pData = static_cast<char *>(pData) + cbAvailable;
00057         }
00058         cbRequested -= cbAvailable;
00059         cbActual += cbAvailable;
00060         readNextBuffer();
00061     }
00062     cbOffset += cbActual;
00063     return cbActual;
00064 }

template<class T>
uint ByteInputStream::readValue ( T &  value  )  [inline, inherited]

Reads a fixed-size value from the stream.

Parameters:
value value to write; type must be memcpy-safe
Returns:
number of bytes actually read

Definition at line 112 of file ByteInputStream.h.

Referenced by FtrsTableWriterFactory::loadIndex(), LogicalTxnTest::loadParticipant(), FtrsTableWriterFactory::loadParticipant(), BTreeRecoveryFactory::loadParticipant(), TupleProjection::readPersistent(), TupleDescriptor::readPersistent(), LogicalTxnTest::redoLogicalAction(), DatabaseTest::redoLogicalAction(), LogicalTxnTest::undoLogicalAction(), and DatabaseTest::undoLogicalAction().

00113     {
00114         return readBytes(&value,sizeof(value));
00115     }

PConstBuffer ByteInputStream::getReadPointer ( uint  cbRequested,
uint pcbActual = NULL 
) [inline, inherited]

Copyless alternative for reading bytes from the stream.

Provides direct access to the stream's internal buffer, but doesn't move the stream position (see consumeReadPointer).

Note that it is in general dangerous to assume that getReadPointer will be able to access desired data items contiguously. For example, a stream created by calling ByteOutputStream::write is likely to have data items split across buffers. The assumption MAY be valid for streams created by calling ByteOutputStream::getWritePointer with matching values for cbRequested; it depends on the stream implementation.

Parameters:
cbRequested number of contiguous bytes to access; if a non-zero number of bytes are currently available in the buffer, cbRequested must be no greater than the number of available bytes (otherwise an assertion violation will result)
pcbActual if non-NULL, receives actual number of contiguous bytes available, which will always be greater than or equal to cbRequested except 0 for end-of-stream
Returns:
pointer to cbActual bytes of available data, or NULL for end-of-stream

Definition at line 209 of file ByteInputStream.h.

References ByteInputStream::getBytesAvailable(), ByteInputStream::pEndByte, ByteInputStream::pNextByte, and ByteInputStream::readNextBuffer().

Referenced by BTreeWriter::deleteLogged(), BTreeWriter::insertLogged(), and BTreeBuildLevel::processInput().

00211 {
00212     if (getBytesAvailable() < cbRequested) {
00213         assert(pNextByte == pEndByte);
00214         readNextBuffer();
00215         if (pNextByte == pEndByte) {
00216             if (pcbActual) {
00217                 *pcbActual = 0;
00218             }
00219             return NULL;
00220         }
00221     }
00222     if (pcbActual) {
00223         *pcbActual = getBytesAvailable();
00224     }
00225     return pNextByte;
00226 }

void ByteInputStream::consumeReadPointer ( uint  cbUsed  )  [inline, inherited]

Advances stream position after a call to getReadPointer.

Parameters:
cbUsed number of bytes to advance; must be less than or equal to the value of cbActual returned by the last call to getReadPointer

Definition at line 234 of file ByteInputStream.h.

References ByteStream::cbOffset, ByteInputStream::getBytesAvailable(), and ByteInputStream::pNextByte.

Referenced by BTreeWriter::deleteLogged(), BTreeWriter::insertLogged(), BTreeBuildLevel::processInput(), and seekSegPos().

00235 {
00236     assert(cbUsed <= getBytesAvailable());
00237     pNextByte += cbUsed;
00238     cbOffset += cbUsed;
00239 }

void ByteInputStream::seekForward ( uint  cb  )  [inline, inherited]

Skips forward in stream.

Parameters:
cb number of bytes to advance

Definition at line 228 of file ByteInputStream.h.

References ByteInputStream::readBytes().

Referenced by ByteInputStream::reset().

00229 {
00230     uint cbActual = readBytes(NULL,cb);
00231     assert(cbActual == cb);
00232 }

void ByteInputStream::seekBackward ( uint  cb  )  [inherited]

Skips backward in stream.

Not all stream implementations support this behavior.

Parameters:
cb number of bytes backward to seek

Definition at line 71 of file ByteInputStream.cpp.

References ByteStream::cbOffset, ByteInputStream::getBytesConsumed(), ByteInputStream::pEndByte, ByteInputStream::pFirstByte, ByteInputStream::pNextByte, and ByteInputStream::readPrevBuffer().

Referenced by ByteInputStream::reset().

00072 {
00073     assert(cb <= cbOffset);
00074     cbOffset -= cb;
00075     if (pNextByte == pFirstByte) {
00076         readPrevBuffer();
00077         pNextByte = pEndByte;
00078     }
00079     for (;;) {
00080         uint cbAvailable = getBytesConsumed();
00081         assert(cbAvailable);
00082         if (cb <= cbAvailable) {
00083             pNextByte -= cb;
00084             break;
00085         }
00086         cb -= cbAvailable;
00087         readPrevBuffer();
00088         pNextByte = pEndByte;
00089     }
00090 }


Member Data Documentation

SegPageIter SegInputStream::pageIter [protected]

Definition at line 43 of file SegInputStream.h.

Referenced by closeImpl(), endPrefetch(), readNextBuffer(), readPrevBuffer(), reset(), seekSegPos(), and startPrefetch().

PageId SegInputStream::currPageId [protected]

PageId of current page.

Definition at line 48 of file SegInputStream.h.

Referenced by closeImpl(), getSegPos(), lockBuffer(), CrcSegInputStream::lockBuffer(), CrcSegInputStream::lockBufferParanoid(), readNextBuffer(), readPrevBuffer(), seekSegPos(), SegInputStream(), and startPrefetch().

bool SegInputStream::shouldDeallocate [protected]

Whether to deallocate stream pages when no longer needed.

Definition at line 53 of file SegInputStream.h.

Referenced by closeImpl(), isDeallocating(), readNextBuffer(), SegInputStream(), and setDeallocate().

SegmentAccessor SegStream::segmentAccessor [protected, inherited]

Accessor for segment containing stream data.

Definition at line 97 of file SegStream.h.

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

SegStreamLock SegStream::pageLock [protected, inherited]

Lock held on current page, if any.

Definition at line 102 of file SegStream.h.

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

uint SegStream::cbPageHeader [protected, inherited]

Number of bytes in page header.

Definition at line 107 of file SegStream.h.

Referenced by SegOutputStream::flushBuffer(), lockBuffer(), CrcSegInputStream::lockBufferParanoid(), SegOutputStream::SegOutputStream(), and SegStream::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(), getSegPos(), ByteInputStream::readBytes(), ByteInputStream::reset(), ByteArrayInputStream::resetArray(), ByteInputStream::seekBackward(), 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:45 2009 for Fennel by  doxygen 1.5.1