PLearn 0.1
Public Types | Public Member Functions | Private Attributes
PLearn::SimpleDBIndexKey< KeyType > Class Template Reference

#include <SimpleDB.h>

Collaboration diagram for PLearn::SimpleDBIndexKey< KeyType >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef KeyType ByteArr
typedef ByteArr::iterator iterator

Public Member Functions

 SimpleDBIndexKey ()
 default ctor
 SimpleDBIndexKey (size_t len)
 SimpleDBIndexKey (const unsigned char *the_raw, size_t len)
 SimpleDBIndexKey (const ByteArr &the_raw)
 operator char * () const
size_t byteLength () const
bool operator== (const SimpleDBIndexKey &other) const
 relational operators
bool operator!= (const SimpleDBIndexKey &other) const
void resize (size_t len)
ByteArr::iterator begin ()
ByteArr::iterator end ()

Private Attributes

ByteArr raw

Detailed Description

template<class KeyType>
class PLearn::SimpleDBIndexKey< KeyType >

An IndexKey is used by hash tables for indexing purposes. It contains* a tiny vector of bytes (cannot be a pointer onto a row, since full row objects are fairly short-lived).

Definition at line 415 of file SimpleDB.h.


Member Typedef Documentation

template<class KeyType >
typedef KeyType PLearn::SimpleDBIndexKey< KeyType >::ByteArr

These is a small semantic clash between what Hash requires and the way database rows are implemented. According to the C++ standard, the only type that is guaranteed to map to any preconceived notion of "amorphous byte" is the unsigned char (assuming 8-bit chars). Hence, all our internal data storage is performed this way. However, Hash works with plain chars, which causes a somewhat annoying compiler complaint of possible conversion error. This is why you see the static_cast in operator char*().

Definition at line 427 of file SimpleDB.h.

template<class KeyType >
typedef ByteArr::iterator PLearn::SimpleDBIndexKey< KeyType >::iterator

Definition at line 428 of file SimpleDB.h.


Constructor & Destructor Documentation

template<class KeyType >
PLearn::SimpleDBIndexKey< KeyType >::SimpleDBIndexKey ( ) [inline]

default ctor

Definition at line 430 of file SimpleDB.h.

template<class KeyType >
PLearn::SimpleDBIndexKey< KeyType >::SimpleDBIndexKey ( size_t  len) [inline, explicit]

Definition at line 432 of file SimpleDB.h.

        : raw(len, '\0') {}
template<class KeyType >
PLearn::SimpleDBIndexKey< KeyType >::SimpleDBIndexKey ( const unsigned char *  the_raw,
size_t  len 
) [inline]

Definition at line 435 of file SimpleDB.h.

References std::copy().

        : raw(len, '\0')
    {
        copy(the_raw, the_raw+len, begin());
    }

Here is the call graph for this function:

template<class KeyType >
PLearn::SimpleDBIndexKey< KeyType >::SimpleDBIndexKey ( const ByteArr the_raw) [inline]

Definition at line 441 of file SimpleDB.h.

        : raw(the_raw) {}

Member Function Documentation

template<class KeyType >
ByteArr::iterator PLearn::SimpleDBIndexKey< KeyType >::begin ( ) [inline]

Definition at line 475 of file SimpleDB.h.

References PLearn::raw.

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

                                     {
        return raw.begin();
    }

Here is the caller graph for this function:

template<class KeyType >
size_t PLearn::SimpleDBIndexKey< KeyType >::byteLength ( ) const [inline]

Definition at line 458 of file SimpleDB.h.

References PLearn::raw.

                              {
        return raw.size();
    }
template<class KeyType >
ByteArr::iterator PLearn::SimpleDBIndexKey< KeyType >::end ( ) [inline]

Definition at line 479 of file SimpleDB.h.

References PLearn::raw.

                                  {
        return raw.end();
    }
template<class KeyType >
PLearn::SimpleDBIndexKey< KeyType >::operator char * ( ) const [inline]

default copy constructor default destructor default assignment operator

REquired interface. There is one small thing that our dear Hash Table class does not account for: operator char*() MUST BE CONST! or otherwise, the conversion operator is not called properly.

Definition at line 454 of file SimpleDB.h.

References PLearn::raw.

                           {
        return (char*)(&raw[0]);
    }
template<class KeyType >
bool PLearn::SimpleDBIndexKey< KeyType >::operator!= ( const SimpleDBIndexKey< KeyType > &  other) const [inline]

Definition at line 467 of file SimpleDB.h.

References PLearn::SimpleDBIndexKey< KeyType >::raw, and PLearn::raw.

                                                         {
        return raw != other.raw;
    }
template<class KeyType >
bool PLearn::SimpleDBIndexKey< KeyType >::operator== ( const SimpleDBIndexKey< KeyType > &  other) const [inline]

relational operators

Definition at line 463 of file SimpleDB.h.

References PLearn::SimpleDBIndexKey< KeyType >::raw, and PLearn::raw.

                                                         {
        return raw == other.raw;
    }
template<class KeyType >
void PLearn::SimpleDBIndexKey< KeyType >::resize ( size_t  len) [inline]

Definition at line 471 of file SimpleDB.h.

References PLearn::raw.

                            {
        raw.resize(len);
    }

Member Data Documentation

template<class KeyType >
ByteArr PLearn::SimpleDBIndexKey< KeyType >::raw [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines