#include <CrcSegInputStream.h>
Inheritance diagram for CrcSegInputStream:
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 () |
| |
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 |
| |
SegmentAccessor const & | getSegmentAccessor () const |
| |
FileSize | getOffset () const |
| |
bool | isClosed () const |
| |
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 | newCrcSegInputStream (SegmentAccessor const &segmentAccessor, PseudoUuid onlineUuid, PageId beginPageId=FIRST_LINEAR_PAGE_ID) |
Creates a new CrcSegInputStream. | |
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. | |
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 |
| |
uint | getBytesConsumed () const |
| |
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 |
Private Member Functions | |
CrcSegInputStream (SegmentAccessor const &segmentAccessor, PseudoUuid onlineUuid, PageId beginPageId) | |
bool | lockBufferParanoid () |
virtual void | lockBuffer () |
Private Attributes | |
PseudoUuid | onlineUuid |
boost::crc_32_type | crcComputer |
An invalid page is interpreted as end of stream.
Definition at line 38 of file CrcSegInputStream.h.
CrcSegInputStream::CrcSegInputStream | ( | SegmentAccessor const & | segmentAccessor, | |
PseudoUuid | onlineUuid, | |||
PageId | beginPageId | |||
) | [explicit, private] |
Definition at line 40 of file CrcSegInputStream.cpp.
References onlineUuid.
Referenced by newCrcSegInputStream().
00044 : SegInputStream(segmentAccessorInit,beginPageId,sizeof(SegStreamCrc)) 00045 { 00046 onlineUuid = onlineUuidInit; 00047 }
bool CrcSegInputStream::lockBufferParanoid | ( | ) | [inline, private] |
Definition at line 49 of file CrcSegInputStream.cpp.
References SegStreamNode::cbData, SegStream::cbPageHeader, SegStreamCrc::checksum, crcComputer, SegInputStream::currPageId, SegNodeLock< Node >::getNodeForRead(), SegPageLock::getPage(), CachePage::isDataValid(), SegNodeLock< Node >::isMagicNumberValid(), SegPageLock::lockShared(), onlineUuid, SegStreamCrc::onlineUuid, SegStreamCrc::pageId, SegStream::pageLock, ByteInputStream::pFirstByte, SegmentAccessor::pSegment, SegStream::segmentAccessor, and ByteInputStream::setBuffer().
Referenced by lockBuffer().
00050 { 00051 if (!segmentAccessor.pSegment->isPageIdAllocated(currPageId)) { 00052 return false; 00053 } 00054 pageLock.lockShared(currPageId); 00055 if (!pageLock.getPage().isDataValid()) { 00056 return false; 00057 } 00058 if (!pageLock.isMagicNumberValid()) { 00059 return false; 00060 } 00061 SegStreamNode const &node = pageLock.getNodeForRead(); 00062 SegStreamCrc const *pCrc = 00063 reinterpret_cast<SegStreamCrc const *>(&node+1); 00064 if (pCrc->pageId != currPageId) { 00065 return false; 00066 } 00067 if (pCrc->onlineUuid != onlineUuid) { 00068 return false; 00069 } 00070 crcComputer.reset(); 00071 crcComputer.process_bytes(pCrc + 1,node.cbData); 00072 if (pCrc->checksum != crcComputer.checksum()) { 00073 return false; 00074 } 00075 PConstBuffer pFirstByte = 00076 reinterpret_cast<PConstBuffer>(&node) + cbPageHeader; 00077 setBuffer(pFirstByte,node.cbData); 00078 return true; 00079 }
void CrcSegInputStream::lockBuffer | ( | ) | [private, virtual] |
Reimplemented from SegInputStream.
Definition at line 81 of file CrcSegInputStream.cpp.
References SegInputStream::currPageId, lockBufferParanoid(), NULL_PAGE_ID, ByteInputStream::nullifyBuffer(), SegStream::pageLock, and SegPageLock::unlock().
00082 { 00083 if (!lockBufferParanoid()) { 00084 pageLock.unlock(); 00085 currPageId = NULL_PAGE_ID; 00086 nullifyBuffer(); 00087 } 00088 }
SharedSegInputStream CrcSegInputStream::newCrcSegInputStream | ( | SegmentAccessor const & | segmentAccessor, | |
PseudoUuid | onlineUuid, | |||
PageId | beginPageId = FIRST_LINEAR_PAGE_ID | |||
) | [static] |
Creates a new CrcSegInputStream.
segmentAccessor | accessor for the segment containing the stream data | |
onlineUuid | PseudoUuid which each page should match | |
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 |
Definition at line 29 of file CrcSegInputStream.cpp.
References CrcSegInputStream(), onlineUuid, and SegStream::segmentAccessor.
Referenced by LogicalRecoveryLog::LogicalRecoveryLog().
00033 { 00034 return SharedSegInputStream( 00035 new CrcSegInputStream( 00036 segmentAccessor,onlineUuid,beginPageId), 00037 ClosableObjectDestructor()); 00038 }
void SegInputStream::readNextBuffer | ( | ) | [protected, virtual, inherited] |
Must be implemented by derived class by calling either setBuffer or nullifyBuffer.
Implements ByteInputStream.
Definition at line 71 of file SegInputStream.cpp.
References SegInputStream::currPageId, SegPageLock::deallocateLockedPage(), SegStream::getSegment(), SegPageLock::isLocked(), SegPageIter::isSingular(), SegInputStream::lockBuffer(), NULL_PAGE_ID, ByteInputStream::nullifyBuffer(), SegInputStream::pageIter, SegStream::pageLock, SegInputStream::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, inherited] |
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, SegInputStream::currPageId, Segment::getLinearBlockNum(), SegStream::getSegment(), SegPageIter::isSingular(), SegInputStream::lockBuffer(), ByteInputStream::nullifyBuffer(), and SegInputStream::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, inherited] |
Must be implemented by derived class to release any resources.
Reimplemented from SegStream.
Definition at line 109 of file SegInputStream.cpp.
References SegStream::closeImpl(), SegInputStream::currPageId, SegPageLock::deallocateUnlockedPage(), SegStream::getSegment(), SegPageIter::makeSingular(), NULL_PAGE_ID, SegInputStream::pageIter, SegStream::pageLock, SegInputStream::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 }
SharedSegInputStream SegInputStream::newSegInputStream | ( | SegmentAccessor const & | segmentAccessor, | |
PageId | beginPageId = FIRST_LINEAR_PAGE_ID | |||
) | [static, inherited] |
Creates a new SegInputStream, positioned at beginning-of-stream.
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 |
Definition at line 29 of file SegInputStream.cpp.
References SegInputStream::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 | ( | ) | [inherited] |
Requests that prefetch be performed in anticipation of forward scan.
Definition at line 52 of file SegInputStream.cpp.
References SegInputStream::currPageId, SegPageIter::mapRange(), SegInputStream::pageIter, and SegStream::segmentAccessor.
Referenced by SegInputStream::reset().
00053 { 00054 pageIter.mapRange(segmentAccessor,currPageId); 00055 }
void SegInputStream::endPrefetch | ( | ) | [inherited] |
Disables prefetch.
Definition at line 57 of file SegInputStream.cpp.
References SegPageIter::makeSingular(), and SegInputStream::pageIter.
Referenced by SegInputStream::reset().
00058 { 00059 pageIter.makeSingular(); 00060 }
void SegInputStream::setDeallocate | ( | bool | shouldDeallocate | ) | [inherited] |
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.
shouldDeallocate | whether to deallocate pages |
Definition at line 145 of file SegInputStream.cpp.
References SegInputStream::shouldDeallocate.
00147 { 00148 shouldDeallocate = shouldDeallocateInit; 00149 }
bool SegInputStream::isDeallocating | ( | ) | [inherited] |
Definition at line 151 of file SegInputStream.cpp.
References SegInputStream::shouldDeallocate.
00152 { 00153 return shouldDeallocate; 00154 }
void SegInputStream::getSegPos | ( | SegStreamPosition & | pos | ) | [virtual, inherited] |
Obtains the current stream position.
pos | receives the position |
Implements SegStream.
Definition at line 123 of file SegInputStream.cpp.
References ByteStream::cbOffset, SegStreamPosition::cbOffset, SegInputStream::currPageId, ByteInputStream::getBytesConsumed(), SegStreamPosition::segByteId, CompoundId::setByteOffset(), and CompoundId::setPageId().
Referenced by SegInputStream::mark().
00124 { 00125 CompoundId::setPageId(pos.segByteId,currPageId); 00126 CompoundId::setByteOffset(pos.segByteId,getBytesConsumed()); 00127 pos.cbOffset = cbOffset; 00128 }
void SegInputStream::seekSegPos | ( | SegStreamPosition const & | pos | ) | [inherited] |
Seeks to a previously recorded stream position.
pos | the new position, previously returned by getSegPos |
Definition at line 130 of file SegInputStream.cpp.
References SegStreamPosition::cbOffset, ByteStream::cbOffset, ByteInputStream::consumeReadPointer(), SegInputStream::currPageId, CompoundId::getByteOffset(), ByteInputStream::getBytesAvailable(), CompoundId::getPageId(), SegPageIter::isSingular(), SegInputStream::lockBuffer(), CompoundId::MAX_BYTE_OFFSET, SegInputStream::pageIter, and SegStreamPosition::segByteId.
Referenced by SegInputStream::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, inherited] |
Creates a new uninitialized marker for this stream.
The returned marker must be passed to mark() in order to initialize it.
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, inherited] |
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.
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 SegInputStream::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, inherited] |
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.
marker | memento previously memorized with mark() |
Reimplemented from ByteInputStream.
Definition at line 171 of file SegInputStream.cpp.
References SegInputStream::endPrefetch(), ByteStreamMarker::getStream(), SegPageIter::isSingular(), SegInputStream::pageIter, SegInputStream::seekSegPos(), SegStreamMarker::segPos, and SegInputStream::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] |
Definition at line 43 of file SegStream.cpp.
References SegmentAccessor::pSegment, and SegStream::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 [inherited] |
Definition at line 48 of file SegStream.cpp.
References SegStream::segmentAccessor.
00049 { 00050 return segmentAccessor; 00051 }
FileSize ByteStream::getOffset | ( | ) | const [inline, inherited] |
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] |
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.
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(), SegInputStream::lockBuffer(), 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(), lockBuffer(), SegInputStream::readNextBuffer(), ByteArrayInputStream::readNextBuffer(), SegInputStream::readPrevBuffer(), and ByteArrayInputStream::readPrevBuffer().
00251 { 00252 setBuffer(NULL,0); 00253 }
uint ByteInputStream::getBytesAvailable | ( | ) | const [inline, protected, inherited] |
Definition at line 199 of file ByteInputStream.h.
References ByteInputStream::pEndByte, and ByteInputStream::pNextByte.
Referenced by ByteInputStream::consumeReadPointer(), ByteInputStream::getReadPointer(), ByteInputStream::readBytes(), and SegInputStream::seekSegPos().
uint ByteInputStream::getBytesConsumed | ( | ) | const [inline, protected, inherited] |
Definition at line 204 of file ByteInputStream.h.
References ByteInputStream::pFirstByte, and ByteInputStream::pNextByte.
Referenced by SegInputStream::getSegPos(), and ByteInputStream::seekBackward().
00205 { 00206 return static_cast<uint>(pNextByte - pFirstByte); 00207 }
Reads bytes from the stream.
pData | target buffer to read into | |
cbRequested | number of bytes to read |
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 }
uint ByteInputStream::readValue | ( | T & | value | ) | [inline, inherited] |
Reads a fixed-size value from the stream.
value | value to write; type must be memcpy-safe |
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.
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 |
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.
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 SegInputStream::seekSegPos().
00235 { 00236 assert(cbUsed <= getBytesAvailable()); 00237 pNextByte += cbUsed; 00238 cbOffset += cbUsed; 00239 }
void ByteInputStream::seekForward | ( | uint | cb | ) | [inline, inherited] |
Skips forward in stream.
cb | number of bytes to advance |
Definition at line 228 of file ByteInputStream.h.
References ByteInputStream::readBytes().
Referenced by ByteInputStream::reset().
void ByteInputStream::seekBackward | ( | uint | cb | ) | [inherited] |
Skips backward in stream.
Not all stream implementations support this behavior.
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 }
PseudoUuid CrcSegInputStream::onlineUuid [private] |
Definition at line 41 of file CrcSegInputStream.h.
Referenced by CrcSegInputStream(), lockBufferParanoid(), and newCrcSegInputStream().
boost::crc_32_type CrcSegInputStream::crcComputer [private] |
SegPageIter SegInputStream::pageIter [protected, inherited] |
Definition at line 43 of file SegInputStream.h.
Referenced by SegInputStream::closeImpl(), SegInputStream::endPrefetch(), SegInputStream::readNextBuffer(), SegInputStream::readPrevBuffer(), SegInputStream::reset(), SegInputStream::seekSegPos(), and SegInputStream::startPrefetch().
PageId SegInputStream::currPageId [protected, inherited] |
PageId of current page.
Definition at line 48 of file SegInputStream.h.
Referenced by SegInputStream::closeImpl(), SegInputStream::getSegPos(), SegInputStream::lockBuffer(), lockBuffer(), lockBufferParanoid(), SegInputStream::readNextBuffer(), SegInputStream::readPrevBuffer(), SegInputStream::seekSegPos(), SegInputStream::SegInputStream(), and SegInputStream::startPrefetch().
bool SegInputStream::shouldDeallocate [protected, inherited] |
Whether to deallocate stream pages when no longer needed.
Definition at line 53 of file SegInputStream.h.
Referenced by SegInputStream::closeImpl(), SegInputStream::isDeallocating(), SegInputStream::readNextBuffer(), SegInputStream::SegInputStream(), and SegInputStream::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(), lockBufferParanoid(), newCrcSegInputStream(), CrcSegOutputStream::newCrcSegOutputStream(), SegInputStream::newSegInputStream(), SegOutputStream::newSegOutputStream(), and SegInputStream::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(), SegInputStream::closeImpl(), SegOutputStream::flushBuffer(), SegInputStream::lockBuffer(), lockBuffer(), lockBufferParanoid(), SegInputStream::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(), SegInputStream::lockBuffer(), 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(), 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().