#include <TDBDiskIndex.h>
Inheritance diagram for Tagcoll::TDBDiskIndex< ITEM, TAG >:
Public Member Functions | |
TDBDiskIndex (const std::string &pkgidx, const std::string &tagidx, const Converter< ITEM, std::string > &fromitem, const Converter< TAG, std::string > &fromtag, const Converter< std::string, ITEM > &toitem, const Converter< std::string, TAG > &totag, bool write=true) | |
Create a new TDBDiskIndex. | |
virtual | ~TDBDiskIndex () |
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 void | output (Consumer< ITEM, TAG > &consumer) const |
Output all the contents of the collection to a Consumer. | |
virtual void | applyChange (const PatchList< ITEM, TAG > &change) |
Apply a patch to the collection. | |
template<> | |
OpSet< string > | getItemsHavingTag (const string &tag) const |
template<> | |
OpSet< string > | getTagsOfItem (const string &item) const |
Protected Member Functions | |
virtual void | consumeItem (const ITEM &item, const OpSet< TAG > &tags) |
Process a tagged item, with its tags. | |
virtual void | consumeItems (const OpSet< ITEM > &items, const OpSet< TAG > &tags) |
Process a set of items identically tagged, with their tags. | |
virtual OpSet< ITEM > | getItemsHavingTag (const TAG &tag) const |
Get the items which are tagged with at least the tag `tag'. | |
virtual OpSet< TAG > | getTagsOfItem (const ITEM &item) const |
Get the tags attached to an item. | |
Protected Attributes | |
TDBFile | pkgdb |
TDBFile | tagdb |
const Converter< ITEM, std::string > & | fromitem |
const Converter< TAG, std::string > & | fromtag |
const Converter< std::string, ITEM > & | toitem |
const Converter< std::string, TAG > & | totag |
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.
TDBDiskIndex::TDBDiskIndex | ( | const std::string & | pkgidx, | |
const std::string & | tagidx, | |||
const Converter< ITEM, std::string > & | fromitem, | |||
const Converter< TAG, std::string > & | fromtag, | |||
const Converter< std::string, ITEM > & | toitem, | |||
const Converter< std::string, TAG > & | totag, | |||
bool | write = true | |||
) |
Create a new TDBDiskIndex.
pkgidx | 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. |
virtual Tagcoll::TDBDiskIndex< ITEM, TAG >::~TDBDiskIndex | ( | ) | [inline, virtual] |
void TDBDiskIndex::consumeItem | ( | const ITEM & | item, | |
const OpSet< TAG > & | tags | |||
) | [protected, virtual] |
void TDBDiskIndex::consumeItems | ( | const OpSet< ITEM > & | items, | |
const OpSet< TAG > & | tags | |||
) | [protected, virtual] |
Process a set of items identically tagged, with their tags.
Reimplemented from Tagcoll::Consumer< ITEM, TAG >.
OpSet< ITEM > TDBDiskIndex::getItemsHavingTag | ( | const TAG & | tag | ) | const [protected, virtual] |
Get the items which are tagged with at least the tag `tag'.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< TAG > TDBDiskIndex::getTagsOfItem | ( | const ITEM & | item | ) | const [protected, virtual] |
Get the tags attached to an item.
item | The item to query |
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
bool TDBDiskIndex::hasTag | ( | const TAG & | tag | ) | const [virtual] |
Check if the collection contains a tag.
tag | The tag to look for |
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< ITEM > TDBDiskIndex::getTaggedItems | ( | ) | const [virtual] |
Get the set of all the items that have tags according to this collection.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< TAG > TDBDiskIndex::getAllTags | ( | ) | const [virtual] |
Get the set of all the tags in this collection.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
int TDBDiskIndex::getCardinality | ( | const TAG & | tag | ) | const [virtual] |
Get the cardinality of tag `tag' (that is, the number of items who have it).
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
void TDBDiskIndex::output | ( | Consumer< ITEM, TAG > & | consumer | ) | const [virtual] |
Output all the contents of the collection to a Consumer.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
void TDBDiskIndex::applyChange | ( | const PatchList< ITEM, TAG > & | change | ) | [virtual] |
Apply a patch to the collection.
Example:
void perform(const PatchList<ITEM, TAG>& change) { collection.applyChange(change); undo.push_back(change.getReverse()); }
Implements Tagcoll::Collection< ITEM, TAG >.
OpSet< string > Tagcoll::TDBDiskIndex< string, string >::getItemsHavingTag | ( | const string & | tag | ) | const |
OpSet< string > Tagcoll::TDBDiskIndex< string, string >::getTagsOfItem | ( | const string & | item | ) | const |
TDBFile Tagcoll::TDBDiskIndex< ITEM, TAG >::pkgdb [protected] |
TDBFile Tagcoll::TDBDiskIndex< ITEM, TAG >::tagdb [protected] |
const Converter<ITEM, std::string>& Tagcoll::TDBDiskIndex< ITEM, TAG >::fromitem [protected] |
const Converter<TAG, std::string>& Tagcoll::TDBDiskIndex< ITEM, TAG >::fromtag [protected] |
const Converter<std::string, ITEM>& Tagcoll::TDBDiskIndex< ITEM, TAG >::toitem [protected] |
const Converter<std::string, TAG>& Tagcoll::TDBDiskIndex< ITEM, TAG >::totag [protected] |