Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::Row Class Reference

#include <SimpleDB.h>

Collaboration diagram for PLearn::Row:

Collaboration graph
[legend]
List of all members.

Public Types

typedef RowIterator iterator
 -- Definition of public nested types

typedef iterator const_iterator
 high-class cheating!

typedef long size_type
 number of elements in a row


Public Member Functions

 Row ()
 Row (const Row &r)
 Row (const Schema *s)
 Construct an empty row given only a schema.

 Row (const vector< unsigned char > &raw, const Schema *s)
 Construct a row given a schema and a full vector of bytes.

iterator begin ()
 Container standard STL functions.

iterator end ()
size_type size () const
 Return the size of a complete row in CHARS!

size_type max_size () const
bool empty () const
const unsigned char * raw () const
 Return the raw data.

unsigned char * raw ()
const SchemagetSchema () const
iterator operator[] (int fieldNumber)
iterator operator[] (string fieldName)
iterator bind (const FieldPtr &p) const
void sanitize () const

Private Attributes

vector< unsigned char > rawrow
const Schemaschema

Detailed Description

A database row is fundamentally a fixed-width byte string. Since we don't want to give direct access to it, we define STL iterators that let us traverse the structure

Definition at line 1047 of file SimpleDB.h.


Member Typedef Documentation

typedef iterator PLearn::Row::const_iterator
 

high-class cheating!

Definition at line 1052 of file SimpleDB.h.

Referenced by PLearn::SDBWithStats::computeStats(), PLearn::AutoSDBVMatrix::getNewRow(), and PLearn::printFieldNames().

typedef RowIterator PLearn::Row::iterator
 

-- Definition of public nested types

Definition at line 1051 of file SimpleDB.h.

Referenced by PLearn::SimpleDB< KeyType, QueryResult >::memoryToDisk(), operator[](), PLearn::printFieldName(), and sanitize().

typedef long PLearn::Row::size_type
 

number of elements in a row

Definition at line 1053 of file SimpleDB.h.


Constructor & Destructor Documentation

PLearn::Row::Row  )  [inline]
 

-- We are now in a position to define the Row public interface. This is fairly simple, since a lot of the work is delegated to the iterator.

Definition at line 1060 of file SimpleDB.h.

PLearn::Row::Row const Row r  )  [inline]
 

Definition at line 1061 of file SimpleDB.h.

PLearn::Row::Row const Schema s  ) 
 

Construct an empty row given only a schema.

Definition at line 781 of file SimpleDB.cc.

References end(), rawrow, and schema.

PLearn::Row::Row const vector< unsigned char > &  raw,
const Schema s
[inline]
 

Construct a row given a schema and a full vector of bytes.

The vector is assumed to be in proper endianness.

Definition at line 1068 of file SimpleDB.h.

References PLearn::raw.


Member Function Documentation

iterator PLearn::Row::begin  )  [inline]
 

Container standard STL functions.

Definition at line 1076 of file SimpleDB.h.

References PLearn::raw.

Referenced by PLearn::SDBWithStats::computeStats(), PLearn::AutoSDBVMatrix::getNewRow(), PLearn::SimpleDB< KeyType, QueryResult >::memoryToDisk(), PLearn::operator<<(), operator[](), PLearn::printFieldNames(), and sanitize().

iterator PLearn::Row::bind const FieldPtr p  )  const [inline]
 

Bind a FieldPtr to a row to produce a row iterator (this would actually be an opportunity to overload operator->*(), note the star, but use restraint and don't do it). Right now, we define binding a null pointer as an error.

Definition at line 1135 of file SimpleDB.h.

References PLearn::FieldPtr::field_index_, PLearn::FieldPtr::offset_, PLERROR, and PLearn::raw.

Referenced by PLearn::SDBVMFieldSumClaims::convertField(), PLearn::SDBVMFieldHasClaim::convertField(), and PLearn::SDBVMSource::getValue().

bool PLearn::Row::empty  )  const [inline]
 

Definition at line 1097 of file SimpleDB.h.

iterator PLearn::Row::end  )  [inline]
 

Definition at line 1080 of file SimpleDB.h.

References PLearn::raw.

Referenced by PLearn::SimpleDB< KeyType, QueryResult >::memoryToDisk(), PLearn::operator<<(), operator[](), PLearn::printFieldNames(), Row(), and sanitize().

const Schema* PLearn::Row::getSchema  )  const [inline]
 

Definition at line 1116 of file SimpleDB.h.

size_type PLearn::Row::max_size  )  const [inline]
 

Definition at line 1093 of file SimpleDB.h.

Row::iterator PLearn::Row::operator[] string  fieldName  ) 
 

Definition at line 824 of file SimpleDB.cc.

References begin(), end(), and schema.

Row::iterator PLearn::Row::operator[] int  fieldNumber  ) 
 

A few utility operators. Note: contrarily to standard containers, operator[] does not return a reference to a type, but an iterator to the proper position within the row. This is done because of the intrinsic polymorphism of row elements. An iterator equal to end() is returned if the field could be accessed/found.

Definition at line 816 of file SimpleDB.cc.

References begin(), end(), and iterator.

unsigned char* PLearn::Row::raw  )  [inline]
 

Definition at line 1109 of file SimpleDB.h.

const unsigned char* PLearn::Row::raw  )  const [inline]
 

Return the raw data.

Definition at line 1102 of file SimpleDB.h.

Referenced by PLearn::SimpleDB< KeyType, QueryResult >::addRow(), PLearn::SimpleDB< KeyType, QueryResult >::findEqualLinear(), PLearn::SimpleDB< KeyType, QueryResult >::getInRow(), PLearn::SimpleDB< KeyType, QueryResult >::indexColumn(), and PLearn::SimpleDB< KeyType, QueryResult >::setRow().

void PLearn::Row::sanitize  )  const
 

This should be called to perform some sanity checking on a row before writing it to disk. This function is marked const, but nevertheless makes invisible changes to the object.

Definition at line 792 of file SimpleDB.cc.

References PLearn::RowIterator::asString(), begin(), end(), iterator, PLearn::RowIterator::precision(), and x.

Referenced by PLearn::SimpleDB< KeyType, QueryResult >::addRow(), and PLearn::SimpleDB< KeyType, QueryResult >::setRow().

size_type PLearn::Row::size  )  const [inline]
 

Return the size of a complete row in CHARS!

Definition at line 1089 of file SimpleDB.h.

Referenced by PLearn::SimpleDB< KeyType, QueryResult >::addRow(), PLearn::SimpleDB< KeyType, QueryResult >::getInRow(), PLearn::SimpleDB< KeyType, QueryResult >::setRow(), and PLearn::SimpleDB< KeyType, QueryResult >::setSchema().


Member Data Documentation

vector<unsigned char> PLearn::Row::rawrow [private]
 

Definition at line 1150 of file SimpleDB.h.

Referenced by Row().

const Schema* PLearn::Row::schema [private]
 

Definition at line 1151 of file SimpleDB.h.

Referenced by operator[](), and Row().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:23:04 2004 for PLearn by doxygen 1.3.7