Tanl Linguistic Pipeline

IXE::Table< T, IndexerClass > Class Template Reference

Inheritance diagram for IXE::Table< T, IndexerClass >:
IXE::Indexable< T >

List of all members.

Classes

class  Cursor
 A Cursor on a Table<T, IndexerClass>. More...

Public Types

enum  DbType { Btree, Hash, FixLen }
typedef T ItemType
typedef Table< T, IndexerClass > TableType

Public Member Functions

char const * tableName ()
 Table (char const *pathname, bool readonly=false, MetaClass *meta=CLASS_OF(T), Size cacheSize=0, DbType DBtype=Btree, Size uniqueElements=0)
 Create table.
 Table (Table const &table)
 Clone table, to be used concurrently by another thread.
 Table (Table const &table, bool readonly)
 Open duplicate table on same DB.
 Table ()
 Used for cloning Collection.
void noFulltextIndexing ()
 Avoid performing fulltext indexing.
void commit ()
 Save changes.
bool insert (ItemType *obj)
 Insert an object in the table.
bool remove (ItemType *obj)
 Remove the stored object with the same primary key as.
bool insertDynamic (AnyObject *obj)
void stopWords (StopWords *stopWords)
 Set the stop list for all fulltext fields.
void stopWords (char const *fieldname, StopWords *stopWords)
 Set the stop list for a given fulltext field.
operator[] (int i) const
 Implement Indexable interface.
DocID getDocID (const char *field, const char *value)
 Get the DocID of a document.
DocID getDocID (ItemType *obj)
 Get the DocID of a document.
void Metadata (byte *obj, MetaClass *metadataClass)
 Get metadata for table.
void Metadata (MetaClass *metadataClass, byte *obj)
 Set metadata for table.
Count size ()
 Return the number of objects in the table.
DocID merge (TableType *table2, Remap &remap)
 Merge this table with another one having the same structure, i.e.
template<class DeleteTest >
DocID merge (TableType *table2, DeleteTest delendum, Remap &remap)
 Merge this table with another one having the same structure, i.e.
std::vector< TCBDB * > & Keys ()
TCBDB * Primary () const
DBTKey ()
FieldPrimaryField () const
Size MaxRowSize () const
DocID LastID ()
void LastID (DocID lastID)
 Sets key of last item in table.

Public Attributes

MetaClassmetaClass
IndexerClass * fulltextIndexer
 indexer for fulltext fields
std::vector< MappedSubFieldmappedFields
 for value type fields
std::vector< SubFieldsubFields
 for fields with Metaclasses

Protected Member Functions

void open (char const *basename, bool readonly, DbType dbType, Size uniqueElements=0, int cacheLeaves=0, int cacheNodes=0)
byte * mappedField (Field *fd, DocID id)
 access the mapped field
void close ()
void LastID (DocID *lastID)
 Fetches key of last item in table.
void fetch (byte *obj, byte *row)
void removeSecondary (ItemType const &obj)
 Remove secondary keys associated to object.
void insertRow (ItemType *obj)
 Auxiliary method for insertion.

Protected Attributes

char const * table_name
TCFDB * metadata
 for storing table metadata (i.e. schema)
TCBDB * primary
 primary key index
TCHDB * unique
 unique key index
std::vector< TCBDB * > keys
 secondary keys
DBT key
 used by insert()
DBT row
 allocated at first insert()
ulonglong keyID
 optimize primary key
DocID lastID
 remember last assigned ID
bool isNew
 whether using existing DB
Count nFulltext
 number of fulltext columns
Count nRows
 not supported by BDB
Count nUnique
 no. of unique fields
FieldautoincrementField
FieldexternalField
FieldprimaryField
FielduniqueField
Size maxRowSize
 max size for row
bool master
 whether this is the master open
DbType dbType
Lock mutex

Friends

class DynamicTable
class Cursor

template<class T, class IndexerClass = TextIndexer>
class IXE::Table< T, IndexerClass >


Member Enumeration Documentation

template<class T, class IndexerClass = TextIndexer>
enum IXE::Table::DbType
Enumerator:
Btree 

B+ tree DB.

Hash 

hash DB

FixLen 

fixed length DB


Constructor & Destructor Documentation

template<class T, class IndexerClass = TextIndexer>
IXE::Table< T, IndexerClass >::Table ( char const *  pathname,
bool  readonly = false,
MetaClass meta = CLASS_OF(T),
Size  cacheSize = 0,
DbType  DBtype = Btree,
Size  uniqueElements = 0 
)

Create table.

Parameters:
pathname base name of files used to store table data
cacheNodes number of non-leaf nodes to be cached
cacheLeaves number of leaf nodes to be cached
DBtype type of database, either Btree (default), Hash or RecNo
uniqueElements estimate of the number of unique elements the table will contain

Member Function Documentation

template<class T, class IndexerClass = TextIndexer>
DocID IXE::Table< T, IndexerClass >::getDocID ( ItemType *  obj  ) 

Get the DocID of a document.

Parameters:
obj obj with a unique key field
template<class T, class IndexerClass = TextIndexer>
DocID IXE::Table< T, IndexerClass >::getDocID ( const char *  field,
const char *  value 
)

Get the DocID of a document.

Parameters:
field name of unique key field
value unique key value

Referenced by IXE::Table< ItemType, IndexerClass >::merge().

template<class T, class IndexerClass = TextIndexer>
bool IXE::Table< T, IndexerClass >::insert ( ItemType *  obj  ) 

Insert an object in the table.

There is no remove() method at the moment since fulltext indexes cannot be updated dynamically. Use merge() to recreate an index without the objects to be removed.

Returns:
true if an object with the same key was already present.

The object may be modified by a reader.

Reimplemented in IXE::DynamicTable.

template<class T, class IndexerClass = TextIndexer>
void IXE::Table< T, IndexerClass >::LastID ( DocID  lastID  )  [inline]

Sets key of last item in table.

Used for Hash tables, since last ID cannot be desumed from last item.

template<class T, class IndexerClass = TextIndexer>
DocID IXE::Table< T, IndexerClass >::LastID (  )  [inline]
Returns:
last assigned ID

Referenced by IXE::Table< ItemType, IndexerClass >::merge().

template<class T, class IndexerClass = TextIndexer>
byte* IXE::Table< T, IndexerClass >::mappedField ( Field fd,
DocID  id 
) [inline, protected]

access the mapped field

Parameters:
fd of document
id. 

Referenced by IXE::Table< T, IndexerClass >::Cursor::get().

template<class T, class IndexerClass = TextIndexer>
template<class DeleteTest >
DocID IXE::Table< T, IndexerClass >::merge ( TableType table2,
DeleteTest  delendum,
Remap remap 
) [inline]

Merge this table with another one having the same structure, i.e.

metaclass, removing some objects. Fulltext indices should be merged separately.

DocIDs of second table are renumbered.

Parameters:
delendum is a functional object that returns true for objects to be deleted. Default is always false, so no object is deleted.
remap will contain for each deleted document the count of preceding deleted documents (used to renumber documents by subtracting this value).
Returns:
the DocID of the last document in the merged table.
template<class T, class IndexerClass = TextIndexer>
DocID IXE::Table< T, IndexerClass >::merge ( TableType table2,
Remap remap 
) [inline]

Merge this table with another one having the same structure, i.e.

metaclass. Fulltext indices should be merged separately.

DocIDs of second table are renumbered:

  1. if doc was already present, with the DocID of the previous copy
  2. otherwise a brand new DocID will be assigned.
Parameters:
remap for duplicate documents it will be filled with map from DocID in table2 to DocID in this table.
Returns:
the DocID of the last document in the merged table.

Referenced by IXE::Table< ItemType, IndexerClass >::merge().

template<class T, class IndexerClass = TextIndexer>
void IXE::Table< T, IndexerClass >::Metadata ( MetaClass metadataClass,
byte *  obj 
)

Set metadata for table.

A single object can be stored as metadata. Such object can be of any class C which has a metaclass.

Parameters:
metadataClass is the metaclass for the object to be stored
obj is an instance of a class whose metaclass is metadataClass
template<class T, class IndexerClass = TextIndexer>
void IXE::Table< T, IndexerClass >::Metadata ( byte *  obj,
MetaClass metadataClass 
)

Get metadata for table.

Parameters:
obj is an object of metaclass is
metadataClass,where to store the metadata.
metadataClass the metaclass for the object to be retrieved.
template<class T, class IndexerClass = TextIndexer>
void IXE::Table< T, IndexerClass >::noFulltextIndexing (  )  [inline]

Avoid performing fulltext indexing.

This is useful for merging, where the fulltext index is created by merging.

template<class T, class IndexerClass = TextIndexer>
void IXE::Table< T, IndexerClass >::open ( char const *  basename,
bool  readonly,
DbType  dbType,
Size  uniqueElements = 0,
int  cacheLeaves = 0,
int  cacheNodes = 0 
) [protected]
Parameters:
basename is the table file pathname without extension.
readonly determines opening mode.
DBtype can be either Btree or Hash.
uniqueElements is an estimate of the number of elements, used to tune the cache size.
cacheLeaves and
cacheNodes are parameters to set @ the cache size.

Referenced by IXE::Table< ItemType, IndexerClass >::Table().

template<class T, class IndexerClass = TextIndexer>
T IXE::Table< T, IndexerClass >::operator[] ( int  i  )  const [inline, virtual]

Implement Indexable interface.

Access element by DocID.

Implements IXE::Indexable< T >.

template<class T, class IndexerClass = TextIndexer>
bool IXE::Table< T, IndexerClass >::remove ( ItemType *  obj  ) 

Remove the stored object with the same primary key as.

Parameters:
obj. This does not update the fulltext index, but calls Indexer::replace(), to add it to its list of documents to be updated.
obj the replacing object
Returns:
true if obj was present
template<class T, class IndexerClass = TextIndexer>
void IXE::Table< T, IndexerClass >::removeSecondary ( ItemType const &  obj  )  [protected]

Remove secondary keys associated to object.

Parameters:
obj the object to be removed
template<class T, class IndexerClass = TextIndexer>
Count IXE::Table< T, IndexerClass >::size (  )  [inline]

Return the number of objects in the table.

Returns:
the number of objects in the table.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
 
Copyright © 2005-2011 G. Attardi. Generated on 4 Mar 2011 by doxygen 1.6.1.