Fennel: FlatFileBuffer Class Reference (original) (raw)

FlatFileBuffer provides data for FlatFileExecStream. More...

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

Inheritance diagram for FlatFileBuffer:

List of all members.

Public Member Functions
FlatFileBuffer (const std::string &path)
Constructs a buffer.
virtual ~FlatFileBuffer ()
void open ()
Opens a file and obtains resources needed for reading the file.
void setStorage (char *pBuffer, uint size)
Sets internal buffers.
uint read ()
Reads more data into buffer, preserving unread data.
char * getReadPtr ()
Returns a pointer to the current row.
char * getEndPtr ()
Returns a pointer to the end of buffer contents.
int getSize ()
Returns the difference between getEndPtr() and getReadPtr().
bool isFull ()
Returns whether buffer has been filled to maximum capacity.
bool isComplete ()
Returns whether entire file has been read.
bool isDone ()
Returns whether the entire file has been read AND the read pointer is equal to (or past) the end pointer.
void setReadPtr (char *ptr)
Consumes buffer contents up to pointer.
bool isClosed () const
**Returns:**whether the object has been closed
void close ()
Closes this object, releasing any unallocated resources.
virtual void initTraceSource (SharedTraceTarget pTraceTarget, std::string name)
For use when initialization has to be deferred until after construction.
void trace (TraceLevel level, std::string message) const
Records a trace message.
bool isTracing () const
**Returns:**true iff tracing is enabled for this source
bool isTracingLevel (TraceLevel level) const
Determines whether a particular level is being traced.
TraceTarget & getTraceTarget () const
**Returns:**the TraceTarget for this source
SharedTraceTarget getSharedTraceTarget () const
**Returns:**the SharedTraceTarget for this source
std::string getTraceSourceName () const
Gets the name of this source.
void setTraceSourceName (std::string const &n)
Sets the name of this source.
TraceLevel getMinimumTraceLevel () const
void disableTracing ()
Protected Attributes
bool needsClose
Private Member Functions
void closeImpl ()
Must be implemented by derived class to release any resources.
Private Attributes
std::string path
FILE * pFile
FileSize filePosition
char * pBuffer
uint bufferSize
uint contentSize
char * pCurrent

Detailed Description

FlatFileBuffer provides data for FlatFileExecStream.

The data is provided as a stream of characters stored in a buffer.

This implementation sequentially reads an ascii file page by page. It handles the details of file access, and manages a pointer to unread data. The file is opened during a call to [open()](classFlatFileBuffer.html#1479ec45e5b4b92a7313126be0a00ad6) and is closed either by an explicit call to [close()](classClosableObject.html#3724341003d56452984b5a49e5144a97) or on deallocation.

Storage must be provided with a call to [setStorage()](classFlatFileBuffer.html#e78bb9f1758c9b79f9add4c87a551896) before calling [read()](classFlatFileBuffer.html#779c9b39fb9c85a38dfcf55d4d9c5ba1). Once [read()](classFlatFileBuffer.html#779c9b39fb9c85a38dfcf55d4d9c5ba1) has been called, [getReadPtr()](classFlatFileBuffer.html#2219507d8f5a87e1829c5252ed0747fe) will return a pointer to the current data pointer. A call to getEnd() will return a pointer to the end of data. A call to [isFull()](classFlatFileBuffer.html#9a122c4706cd5d128ec485b68bc1c1dc) describes whether more data can be read without consuming some. A call to [isComplete()](classFlatFileBuffer.html#3e406f193a42e0876822870d289972a0) describes whether or not the file has been completely read.

The method [setReadPtr()](classFlatFileBuffer.html#877c0e494984f5a0fb774dea856ba906) may be used to consume input data. Upon reaching the end of the buffer, subsequent calls to [read()](classFlatFileBuffer.html#779c9b39fb9c85a38dfcf55d4d9c5ba1) are used to fetch more data. Unread data is preserved, but the current read pointer may be updated.

FIXME: This class should use a special character pointer. It may be updated to handle unicode. It may be refined to prefetch pages for better performance.

Version:

Id

//open/dev/fennel/flatfile/FlatFileBuffer.h#2

Definition at line 73 of file FlatFileBuffer.h.


Constructor & Destructor Documentation

FlatFileBuffer::FlatFileBuffer ( const std::string & path )

| FlatFileBuffer::~FlatFileBuffer | ( | | ) | [virtual] | | -------------------------------- | - | | - | ----------- |


Member Function Documentation

| void FlatFileBuffer::closeImpl | ( | | ) | [private, virtual] | | ------------------------------ | - | | - | -------------------- |

| void FlatFileBuffer::open | ( | | ) | | ------------------------- | - | | - |

void FlatFileBuffer::setStorage ( char * pBuffer,
uint size
)

| uint FlatFileBuffer::read | ( | | ) | | -------------------------------------------------------------------------------------- | - | | - |

| char * FlatFileBuffer::getReadPtr | ( | | ) | | ---------------------------------- | - | | - |

| char * FlatFileBuffer::getEndPtr | ( | | ) | | --------------------------------- | - | | - |

| int FlatFileBuffer::getSize | ( | | ) | | --------------------------- | - | | - |

| bool FlatFileBuffer::isFull | ( | | ) | | --------------------------- | - | | - |

| bool FlatFileBuffer::isComplete | ( | | ) | | ------------------------------- | - | | - |

| bool FlatFileBuffer::isDone | ( | | ) | | --------------------------- | - | | - |

void FlatFileBuffer::setReadPtr ( char * ptr )

| 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(), open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().

void TraceSource::initTraceSource ( SharedTraceTarget pTraceTarget,
std::string name
) [virtual, inherited]
void TraceSource::trace ( TraceLevel level,
std::string message
) const [inherited]

| bool TraceSource::isTracing | ( | | ) | const [inline, inherited] | | --------------------------- | - | | - | --------------------------- |

bool TraceSource::isTracingLevel ( TraceLevel level ) const [inline, inherited]

| TraceTarget& TraceSource::getTraceTarget | ( | | ) | const [inline, inherited] | | ----------------------------------------------------------------- | - | | - | --------------------------- |

| std::string TraceSource::getTraceSourceName | ( | | ) | const [inline, inherited] | | ------------------------------------------- | - | | - | --------------------------- |

void TraceSource::setTraceSourceName ( std::string const & n ) [inline, inherited]

Sets the name of this source.

Useful to construct dynamic names for fine-grained filtering.

Definition at line 136 of file TraceSource.h.

00137 { 00138 name = n; 00139 }

| TraceLevel TraceSource::getMinimumTraceLevel | ( | | ) | const [inline, inherited] | | ------------------------------------------------------------------------------------------------------ | - | | - | --------------------------- |

| void TraceSource::disableTracing | ( | | ) | [inherited] | | -------------------------------- | - | | - | ------------- |


Member Data Documentation


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


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