#include <SegBufferReader.h>
Inheritance diagram for SegBufferReader:
Public Member Functions | |
SegBufferReader (SharedExecStreamBufAccessor &pOutAccessorInit, SegmentAccessor const &bufferSegmentAccessorInit, PageId firstPageIdInit) | |
Creates a new SegBufferReader object. | |
void | open (bool destroy) |
Initiates reads of the buffered data, beginning at the first page. | |
ExecStreamResult | read () |
Reads the buffered data. | |
virtual void | closeImpl () |
Must be implemented by derived class to release any resources. | |
bool | isClosed () const |
| |
void | close () |
Closes this object, releasing any unallocated resources. | |
Static Public Member Functions | |
static SharedSegBufferReader | newSegBufferReader (SharedExecStreamBufAccessor &pOutAccessor, SegmentAccessor const &bufferSegmentAccessor, PageId firstPageId) |
Creates a shared pointer to a new SegBufferReader object. | |
Protected Attributes | |
bool | needsClose |
Private Attributes | |
SharedExecStreamBufAccessor | pOutAccessor |
SegmentAccessor | bufferSegmentAccessor |
SharedSegInputStream | pByteInputStream |
PageId | firstPageId |
SegStreamPosition | restartPos |
uint | cbLastRead |
Definition at line 41 of file SegBufferReader.h.
SegBufferReader::SegBufferReader | ( | SharedExecStreamBufAccessor & | pOutAccessorInit, | |
SegmentAccessor const & | bufferSegmentAccessorInit, | |||
PageId | firstPageIdInit | |||
) | [explicit] |
Creates a new SegBufferReader object.
pOutAccessorInit | the output stream that will be written | |
bufferSegmentAccessorInit | the segment accessor that will be used to read the buffered data | |
firstPageIdInit | the pageId of the first buffer page |
Definition at line 41 of file SegBufferReader.cpp.
Referenced by newSegBufferReader().
00045 : pOutAccessor(pOutAccessorInit), 00046 bufferSegmentAccessor(bufferSegmentAccessorInit), 00047 firstPageId(firstPageIdInit) 00048 { 00049 }
SharedSegBufferReader SegBufferReader::newSegBufferReader | ( | SharedExecStreamBufAccessor & | pOutAccessor, | |
SegmentAccessor const & | bufferSegmentAccessor, | |||
PageId | firstPageId | |||
) | [static] |
Creates a shared pointer to a new SegBufferReader object.
pOutAccessor | the output stream that will be written | |
bufferSegmentAccessor | the segment accessor that will be used to read the buffered data | |
firstPageId | the pageId of the first buffer page |
Definition at line 31 of file SegBufferReader.cpp.
References bufferSegmentAccessor, and SegBufferReader().
Referenced by SegBufferReaderExecStream::execute(), and SegBufferExecStream::openBufferForRead().
00035 { 00036 return SharedSegBufferReader( 00037 new SegBufferReader(pOutAccessor, bufferSegmentAccessor, firstPageId), 00038 ClosableObjectDestructor()); 00039 }
void SegBufferReader::open | ( | bool | destroy | ) |
Initiates reads of the buffered data, beginning at the first page.
destroy | if true, destroy the buffered pages after they've been read |
Definition at line 51 of file SegBufferReader.cpp.
References bufferSegmentAccessor, cbLastRead, firstPageId, SegInputStream::newSegInputStream(), pByteInputStream, and restartPos.
00052 { 00053 cbLastRead = 0; 00054 // If previously opened, restart from the beginning 00055 if (pByteInputStream) { 00056 pByteInputStream->endPrefetch(); 00057 pByteInputStream->seekSegPos(restartPos); 00058 } else { 00059 pByteInputStream = 00060 SegInputStream::newSegInputStream( 00061 bufferSegmentAccessor, 00062 firstPageId); 00063 pByteInputStream->getSegPos(restartPos); 00064 } 00065 if (destroy) { 00066 pByteInputStream->setDeallocate(true); 00067 } 00068 pByteInputStream->startPrefetch(); 00069 }
ExecStreamResult SegBufferReader::read | ( | ) |
Reads the buffered data.
Definition at line 71 of file SegBufferReader.cpp.
References cbLastRead, EXECBUF_EMPTY, EXECBUF_EOS, EXECBUF_NONEMPTY, EXECBUF_OVERFLOW, EXECBUF_UNDERFLOW, EXECRC_BUF_OVERFLOW, EXECRC_EOS, pByteInputStream, and pOutAccessor.
00072 { 00073 switch (pOutAccessor->getState()) { 00074 case EXECBUF_NONEMPTY: 00075 case EXECBUF_OVERFLOW: 00076 return EXECRC_BUF_OVERFLOW; 00077 case EXECBUF_UNDERFLOW: 00078 case EXECBUF_EMPTY: 00079 break; 00080 case EXECBUF_EOS: 00081 return EXECRC_EOS; 00082 default: 00083 permAssert(false); 00084 } 00085 00086 pByteInputStream->consumeReadPointer(cbLastRead); 00087 PConstBuffer pBuffer = pByteInputStream->getReadPointer(1,&cbLastRead); 00088 if (!pBuffer) { 00089 pOutAccessor->markEOS(); 00090 return EXECRC_EOS; 00091 } 00092 pOutAccessor->provideBufferForConsumption( 00093 pBuffer, 00094 pBuffer + cbLastRead); 00095 return EXECRC_BUF_OVERFLOW; 00096 }
void SegBufferReader::closeImpl | ( | ) | [virtual] |
Must be implemented by derived class to release any resources.
Implements ClosableObject.
Definition at line 98 of file SegBufferReader.cpp.
References pByteInputStream.
00099 { 00100 pByteInputStream.reset(); 00101 }
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 }
PageId SegBufferReader::firstPageId [private] |
SegStreamPosition SegBufferReader::restartPos [private] |
uint SegBufferReader::cbLastRead [private] |
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().