Fennel: ByteArrayInputStream Class Reference (original) (raw)
ByteArrayInputStream implements the ByteInputStream interface by reading data from an existing fixed-size array of bytes. More...
#include <[ByteArrayInputStream.h](ByteArrayInputStream%5F8h-source.html)>
Inheritance diagram for ByteArrayInputStream:

| Public Member Functions | |
|---|---|
| void | resetArray (PConstBuffer pBuffer, uint cbBuffer) |
| Resets stream to read from a new array. | |
| uint | readBytes (void *pData, uint cbRequested) |
| Reads bytes from the stream. | |
| template | |
| 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. | |
| 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. | |
| 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. | |
| Static Public Member Functions | |
| static SharedByteArrayInputStream | newByteArrayInputStream (PConstBuffer pBuffer, uint cbBuffer) |
| Creates a new ByteArrayInputStream. | |
| Protected Member Functions | |
| 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 | |
| FileSize | cbOffset |
| Byte position in stream. | |
| bool | needsClose |
| Private 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. | |
| ByteArrayInputStream (PConstBuffer pBuffer, uint cbBuffer) |
Detailed Description
ByteArrayInputStream implements the ByteInputStream interface by reading data from an existing fixed-size array of bytes.
Definition at line 35 of file ByteArrayInputStream.h.
Constructor & Destructor Documentation
| ByteArrayInputStream::ByteArrayInputStream | ( | PConstBuffer | pBuffer, |
|---|---|---|---|
| uint | cbBuffer | ||
| ) | [explicit, private] |
Member Function Documentation
| void ByteArrayInputStream::readNextBuffer | ( | | ) | [private, virtual] | | ----------------------------------------- | - | | - | -------------------- |
| void ByteArrayInputStream::readPrevBuffer | ( | | ) | [private, virtual] | | ----------------------------------------- | - | | - | -------------------- |
| void ByteArrayInputStream::closeImpl | ( | | ) | [private, virtual] | | ------------------------------------ | - | | - | -------------------- |
| void ByteInputStream::setBuffer | ( | PConstBuffer | pBuffer, |
|---|---|---|---|
| uint | cbBuffer | ||
| ) | [inline, protected, inherited] |
| void ByteInputStream::nullifyBuffer | ( | | ) | [inline, protected, inherited] | | ----------------------------------- | - | | - | -------------------------------- |
| uint ByteInputStream::getBytesAvailable | ( | | ) | const [inline, protected, inherited] | | ---------------------------------------------------------------------------------------------------- | - | | - | -------------------------------------- |
| uint ByteInputStream::getBytesConsumed | ( | | ) | const [inline, protected, inherited] | | --------------------------------------------------------------------------------------------------- | - | | - | -------------------------------------- |
| uint ByteInputStream::readBytes | ( | void * | pData, |
|---|---|---|---|
| uint | cbRequested | ||
| ) | [inherited] |
template
| 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().
| void ByteInputStream::consumeReadPointer | ( | uint | cbUsed | ) | [inline, inherited] |
|---|
| void ByteInputStream::seekForward | ( | uint | cb | ) | [inline, inherited] |
|---|
| void ByteInputStream::seekBackward | ( | uint | cb | ) | [inherited] |
|---|
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 in SegInputStream.
Definition at line 92 of file ByteInputStream.cpp.
| void ByteInputStream::reset | ( | ByteStreamMarker const & | marker | ) | [virtual, 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().
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(), SegOutputStream::getSegPos(), SegInputStream::getSegPos(), ByteInputStream::readBytes(), ByteInputStream::reset(), resetArray(), ByteInputStream::seekBackward(), SegInputStream::seekSegPos(), and ByteOutputStream::writeBytes().
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/common/ByteArrayInputStream.h
- /home/pub/open/dev/fennel/common/ByteArrayInputStream.cpp
