Fennel: ByteInputStream Class Reference (original) (raw)

ByteInputStream defines an interface for reading from a stream of bytes. More...

#include <[ByteInputStream.h](ByteInputStream%5F8h-source.html)>

Inheritance diagram for ByteInputStream:

List of all members.

Public Member Functions
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.
Protected Member Functions
ByteInputStream ()
virtual void readNextBuffer ()=0
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.
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
virtual void closeImpl ()=0
Must be implemented by derived class to release any resources.
Protected Attributes
FileSize cbOffset
Byte position in stream.
bool needsClose
Private Attributes
PConstBuffer pFirstByte
First buffered byte of data.
PConstBuffer pNextByte
Next buffered byte of data.
PConstBuffer pEndByte
End of buffer (one past last byte of data in buffer).

Detailed Description

ByteInputStream defines an interface for reading from a stream of bytes.

Definition at line 34 of file ByteInputStream.h.


Constructor & Destructor Documentation

| ByteInputStream::ByteInputStream | ( | | ) | [explicit, protected] | | -------------------------------- | - | | - | ----------------------- |


Member Function Documentation

| virtual void ByteInputStream::readNextBuffer | ( | | ) | [protected, pure virtual] | | -------------------------------------------- | - | | - | --------------------------- |

| void ByteInputStream::readPrevBuffer | ( | | ) | [protected, virtual] | | ------------------------------------ | - | | - | ---------------------- |

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

| void ByteInputStream::nullifyBuffer | ( | | ) | [inline, protected] | | ----------------------------------- | - | | - | --------------------- |

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

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

uint ByteInputStream::readBytes ( void * pData,
uint cbRequested
)

template

uint ByteInputStream::readValue ( T & value ) [inline]

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 }

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 getBytesAvailable(), pEndByte, pNextByte, and readNextBuffer().

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

void ByteInputStream::consumeReadPointer ( uint cbUsed ) [inline]
void ByteInputStream::seekForward ( uint cb ) [inline]
void ByteInputStream::seekBackward ( uint cb )

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.

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

| virtual void ClosableObject::closeImpl | ( | | ) | [protected, pure virtual, inherited] | | -------------------------------------- | - | | - | -------------------------------------- |

Must be implemented by derived class to release any resources.

Implemented in CacheImpl< PageT, VictimPolicyT >, ByteArrayInputStream, ByteArrayOutputStream, ByteOutputStream, CheckpointThread, Database, BarrierExecStream, DoubleBufferExecStream, ExecStream, ExecStreamGraphImpl, MockResourceExecStream, ReshapeExecStream, ScratchBufferExecStream, SegBufferExecStream, SegBufferReader, SegBufferReaderExecStream, SegBufferWriter, SegBufferWriterExecStream, JavaSinkExecStream, JavaTransformExecStream, FlatFileBuffer, FlatFileExecStreamImpl, BTreeExecStream, BTreeInsertExecStream, BTreePrefetchSearchExecStream, BTreeReadExecStream, BTreeSearchExecStream, FtrsTableWriterExecStream, LhxAggExecStream, LhxJoinExecStream, LbmBitOpExecStream, LbmChopperExecStream, LbmGeneratorExecStream, LbmIntersectExecStream, LbmMinusExecStream, LbmSplicerExecStream, LbmUnionExecStream, LcsClusterAppendExecStream, LcsRowScanBaseExecStream, LcsRowScanExecStream, DelegatingSegment, DynamicDelegatingSegment, ScratchSegment, SegInputStream, Segment, SegOutputStream, SegPageBackupRestoreDevice, SegStream, SegStreamAllocation, SpillOutputStream, and ExternalSortExecStreamImpl.

Referenced by ClosableObject::close().

| 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(), consumeReadPointer(), ByteOutputStream::consumeWritePointer(), ByteStream::getOffset(), SegOutputStream::getSegPos(), SegInputStream::getSegPos(), readBytes(), reset(), ByteArrayInputStream::resetArray(), seekBackward(), SegInputStream::seekSegPos(), and ByteOutputStream::writeBytes().


The documentation for this class was generated from the following files:


Generated on Mon Jun 22 04:00:26 2009 for Fennel by doxygen 1.5.1