X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.h;h=7407014e7bd17c0870ad9eee0e43e1d0db3eb6bd;hb=149ded5acd5eb350de9ed118ddb1ba359c984c3f;hp=8fc6596788735b885b3f74aad6e1bea6eaa48883;hpb=0bf9688e2615a9fc07860c5762240e4ce26ee5d3;p=SXSI%2FXMLTree.git diff --git a/XMLTree.h b/XMLTree.h index 8fc6596..7407014 100644 --- a/XMLTree.h +++ b/XMLTree.h @@ -19,21 +19,26 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ******************************************************************************/ +#ifndef XMLTREE_H_ +#define XMLTREE_H_ +#include "TextCollection/TextCollection.h" #include #include +#include #include "bp.h" -#include "libcds/includes/static_bitsequence.h" -#include "libcds/includes/alphabet_mapper.h" -#include "libcds/includes/static_sequence.h" +#include +#include +#include +using SXSI::TextCollection; -//#include "TextCollection/TextCollection.h" -//using SXSI::TextCollection; // this constant is used to efficiently compute the child operation in the tree #define OPTD 10 #define NULLT -1 +#define PERM_SAMPLE 10 + // sets bit p in e #define bitset(e,p) ((e)[(p)/W] |= (1<<((p)%W))) // cleans bit p in e @@ -64,10 +69,10 @@ class XMLTree { static_bitsequence_rrr02 *EBVector; /** Tag sequence represented with a data structure for rank and select */ - static_sequence_wvtree *Tags; + static_sequence *Tags; /** The texts in the XML document */ - //TextCollection *Text; + TextCollection *Text; /** Flag indicating whether the whole data structure has been constructed or * not. If the value is true, you cannot add more texts, nodes, etc. */ @@ -82,6 +87,7 @@ class XMLTree { pb *par_aux; TagType *tags_aux; int npar; + int parArraySize; int ntagnames; unsigned int *empty_texts_aux; @@ -248,13 +254,99 @@ public: * Returns NULL in case that the tag identifier is not valid.*/ unsigned char *GetTagName(TagType tagid); - /** saveXMLTree: saves XML tree data structure to file. Every component of - * the collection is stored in different files (same name, different file - * extensions). */ + /** Prefix(s): search for texts prefixed by string s. */ + TextCollection::document_result Prefix(uchar const *s) { + return Text->Prefix(s); + } + + /** Suffix(s): search for texts having string s as a suffix. */ + TextCollection::document_result Suffix(uchar const *s) { + return Text->Suffix(s); + } + + /** Equal(s): search for texts equal to string s. */ + TextCollection::document_result Equal(uchar const *s) { + return Text->Equal(s); + } + + /** Contains(s): search for texts containing string s. */ + TextCollection::document_result Contains(uchar const *s) { + return Text->Contains(s); + } + + /** LessThan(s): returns document identifiers for the texts that + * are lexicographically smaller than string s. */ + TextCollection::document_result LessThan(uchar const *s) { + return Text->LessThan(s); + } + + /** IsPrefix(x): returns true if there is a text prefixed by string s. */ + bool IsPrefix(uchar const *s) { + return Text->IsPrefix(s); + } + + /** IsSuffix(s): returns true if there is a text having string s as a + * suffix.*/ + bool IsSuffix(uchar const *s) { + return Text->IsSuffix(s); + } + + /** IsEqual(s): returns true if there is a text that equals given + * string s. */ + bool IsEqual(uchar const *s) { + return Text->IsEqual(s); + } + + /** IsContains(s): returns true if there is a text containing string s. */ + bool IsContains(uchar const *s) { + return Text->IsContains(s); + } + + /** IsLessThan(s): returns true if there is at least a text that is + * lexicographically smaller than string s. */ + bool IsLessThan(uchar const *s) { + return Text->IsLessThan(s); + } + + /** CountPrefix(s): counting version of Prefix(s). */ + unsigned CountPrefix(uchar const *s) { + return Text->CountPrefix(s); + } + + /** CountSuffix(s): counting version of Suffix(s). */ + unsigned CountSuffix(uchar const *s) { + return Text->CountSuffix(s); + } + + /** CountEqual(s): counting version of Equal(s). */ + unsigned CountEqual(uchar const *s) { + return Text->CountEqual(s); + } + + /** CountContains(s): counting version of Contains(s). */ + unsigned CountContains(uchar const *s) { + return Text->CountContains(s); + } + + /** CountLessThan(s): counting version of LessThan(s). */ + unsigned CountLessThan(uchar const *s) { + return CountLessThan(s); + } + + /** GetText(d): returns the text corresponding to document with + * id d. */ + uchar* GetText(DocID d) { + return Text->GetText(d); + } + + TextCollection *getTextCollection() { + return Text; + } + /** Save: saves XML tree data structure to file. */ void Save(unsigned char *filename); - /** load: loads XML tree data structure from file. */ + /** Load: loads XML tree data structure from file. sample_rate_text + * indicates the sample rate for the text search data structure. */ static XMLTree *Load(unsigned char *filename, int sample_rate_text); }; - - +#endif