Tagcoll::IntDiskIndex< ITEM, TAG > Class Template Reference

Full TaggedCollection implementation on top of a persistent on-disk TDB database. More...

#include <IntDiskIndex.h>

Inheritance diagram for Tagcoll::IntDiskIndex< ITEM, TAG >:

Inheritance graph
[legend]
Collaboration diagram for Tagcoll::IntDiskIndex< ITEM, TAG >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 IntDiskIndex ()
 Create a new IntDiskIndex.
 IntDiskIndex (const MasterMMapIndex &master, int pkgindex, int tagindex, const Converter< ITEM, int > *fromitem, const Converter< TAG, int > *fromtag, const Converter< int, ITEM > *toitem, const Converter< int, TAG > *totag)
virtual ~IntDiskIndex ()
void init (const MasterMMapIndex &master, int pkgindex, int tagindex, const Converter< ITEM, int > *fromitem, const Converter< TAG, int > *fromtag, const Converter< int, ITEM > *toitem, const Converter< int, TAG > *totag)
void init (const MasterMMapIndex &master, int pkgindex, int tagindex)
virtual bool hasTag (const TAG &tag) const
 Check if the collection contains a tag.
virtual OpSet< ITEM > getTaggedItems () const
 Get the set of all the items that have tags according to this collection.
virtual OpSet< TAG > getAllTags () const
 Get the set of all the tags in this collection.
virtual int getCardinality (const TAG &tag) const
 Get the cardinality of tag `tag' (that is, the number of items who have it).
virtual OpSet< TAG > getCompanionTags (const OpSet< TAG > &tags) const
 Get the set of all tags in this collection that appear in tagsets containing `tags'.
virtual void output (Consumer< ITEM, TAG > &consumer) const
 Output all the contents of the collection to a Consumer.

Protected Member Functions

int fromitem (const ITEM &tag) const
int fromtag (const TAG &tag) const
ITEM toitem (const int &tag) const
TAG totag (const int &tag) const
virtual OpSet< ITEM > getItemsHavingTag (const TAG &tag) const
 Get the items which are tagged with at least the tag `tag'.
virtual OpSet< ITEM > getItemsHavingTags (const OpSet< TAG > &tags) const
 Get the items which are tagged with at least the tags `tags'.
virtual OpSet< TAG > getTagsOfItem (const ITEM &item) const
 Get the tags attached to an item.
virtual OpSet< TAG > getTagsOfItems (const OpSet< ITEM > &items) const
 Get all the tags attached to the items in a set.

Protected Attributes

IntIndex pkgidx
IntIndex tagidx
const Converter< ITEM, int > * m_fromitem
const Converter< TAG, int > * m_fromtag
const Converter< int, ITEM > * m_toitem
const Converter< int, TAG > * m_totag

Detailed Description

template<class ITEM, class TAG>
class Tagcoll::IntDiskIndex< ITEM, TAG >

Full TaggedCollection implementation on top of a persistent on-disk TDB database.

It allows to efficiently query a collection without having to store it all into memory.

If used for heavy modifications, the performance is slower compared to other in-memory collections. If database writes are mainly used for populating the index, then TDBIndexer should be used to create the index and TDBDiskIndex to access it afterwards.


Constructor & Destructor Documentation

template<class ITEM, class TAG>
Tagcoll::IntDiskIndex< ITEM, TAG >::IntDiskIndex (  )  [inline]

Create a new IntDiskIndex.

Parameters:
filename The file name of the package index
tagidx The file name of the tag index
fromitem,fromtag,toitem,totag The Converter-s used to convert ITEMS and TAGS to and from strings. If 0 is passed, this TDBDiskIndex will only be able to work with string items and string tags.
write Set to false if the index should be opened in read-only mode. If opened in read-only mode, all non-const methods of this class will throw an exception if invoked. It defaults to true.

template<class ITEM, class TAG>
Tagcoll::IntDiskIndex< ITEM, TAG >::IntDiskIndex ( const MasterMMapIndex master,
int  pkgindex,
int  tagindex,
const Converter< ITEM, int > *  fromitem,
const Converter< TAG, int > *  fromtag,
const Converter< int, ITEM > *  toitem,
const Converter< int, TAG > *  totag 
) [inline]

template<class ITEM, class TAG>
virtual Tagcoll::IntDiskIndex< ITEM, TAG >::~IntDiskIndex (  )  [inline, virtual]


Member Function Documentation

template<class ITEM, class TAG>
int Tagcoll::IntDiskIndex< ITEM, TAG >::fromitem ( const ITEM &  tag  )  const [inline, protected]

template<class ITEM, class TAG>
int Tagcoll::IntDiskIndex< ITEM, TAG >::fromtag ( const TAG &  tag  )  const [inline, protected]

template<class ITEM, class TAG>
ITEM Tagcoll::IntDiskIndex< ITEM, TAG >::toitem ( const int &  tag  )  const [inline, protected]

template<class ITEM, class TAG>
TAG Tagcoll::IntDiskIndex< ITEM, TAG >::totag ( const int &  tag  )  const [inline, protected]

template<typename ITEM, typename TAG>
OpSet< ITEM > IntDiskIndex::getItemsHavingTag ( const TAG &  tag  )  const [protected, virtual]

Get the items which are tagged with at least the tag `tag'.

Returns:
The items found, or an empty set if no items have that tag

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet< ITEM > IntDiskIndex::getItemsHavingTags ( const OpSet< TAG > &  tags  )  const [protected, virtual]

Get the items which are tagged with at least the tags `tags'.

Returns:
The items found, or an empty set if no items have that tag

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet< TAG > IntDiskIndex::getTagsOfItem ( const ITEM &  item  )  const [protected, virtual]

Get the tags attached to an item.

Parameters:
item The item to query
Returns:
The set of tags, or an empty set if the item has no tags or it does not exist.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet< TAG > IntDiskIndex::getTagsOfItems ( const OpSet< ITEM > &  items  )  const [protected, virtual]

Get all the tags attached to the items in a set.

Parameters:
items The items to query
Returns:
The set of tags, or an empty set if the items have no tags or do not exist.

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
void Tagcoll::IntDiskIndex< ITEM, TAG >::init ( const MasterMMapIndex master,
int  pkgindex,
int  tagindex,
const Converter< ITEM, int > *  fromitem,
const Converter< TAG, int > *  fromtag,
const Converter< int, ITEM > *  toitem,
const Converter< int, TAG > *  totag 
) [inline]

template<class ITEM, class TAG>
void Tagcoll::IntDiskIndex< ITEM, TAG >::init ( const MasterMMapIndex master,
int  pkgindex,
int  tagindex 
) [inline]

template<class ITEM, class TAG>
virtual bool Tagcoll::IntDiskIndex< ITEM, TAG >::hasTag ( const TAG &  tag  )  const [inline, virtual]

Check if the collection contains a tag.

Parameters:
tag The tag to look for
Returns:
true if the collection contains tag, false otherwise

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet< ITEM > IntDiskIndex::getTaggedItems (  )  const [virtual]

Get the set of all the items that have tags according to this collection.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet< TAG > IntDiskIndex::getAllTags (  )  const [virtual]

Get the set of all the tags in this collection.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
virtual int Tagcoll::IntDiskIndex< ITEM, TAG >::getCardinality ( const TAG &  tag  )  const [inline, virtual]

Get the cardinality of tag `tag' (that is, the number of items who have it).

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet< TAG > IntDiskIndex::getCompanionTags ( const OpSet< TAG > &  tags  )  const [virtual]

Get the set of all tags in this collection that appear in tagsets containing `tags'.

Example:

 void refineSelection(const OpSet<Tag>& selection)
 {
    OpSet<Tag> extraTags = collection.getCompanionTags(selection);
    tagMenu.setAvailableOptions(extraTags);
 }

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<typename ITEM, typename TAG>
void IntDiskIndex::output ( Consumer< ITEM, TAG > &  consumer  )  const [virtual]

Output all the contents of the collection to a Consumer.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.


Member Data Documentation

template<class ITEM, class TAG>
IntIndex Tagcoll::IntDiskIndex< ITEM, TAG >::pkgidx [protected]

template<class ITEM, class TAG>
IntIndex Tagcoll::IntDiskIndex< ITEM, TAG >::tagidx [protected]

template<class ITEM, class TAG>
const Converter<ITEM, int>* Tagcoll::IntDiskIndex< ITEM, TAG >::m_fromitem [protected]

template<class ITEM, class TAG>
const Converter<TAG, int>* Tagcoll::IntDiskIndex< ITEM, TAG >::m_fromtag [protected]

template<class ITEM, class TAG>
const Converter<int, ITEM>* Tagcoll::IntDiskIndex< ITEM, TAG >::m_toitem [protected]

template<class ITEM, class TAG>
const Converter<int, TAG>* Tagcoll::IntDiskIndex< ITEM, TAG >::m_totag [protected]


The documentation for this class was generated from the following files:
Generated on Sat Jan 17 03:40:21 2009 for libtagcoll by  doxygen 1.5.1