\r
\r
XMLTree::XMLTree( pb * const par, uint npar, vector<string> * const TN, TagIdMap * const tim, uint *empty_texts_bmp, TagType *tags,\r
- TextCollection * const TC, vector<string> * const CT, bool dis_tc)\r
+ TextCollection * const TC, bool dis_tc)\r
\r
{\r
// creates the data structure for the tree topology\r
\r
Text = (TextCollection*) TC;\r
\r
- CachedText = (vector<string>*) CT;\r
+\r
EBVector = new static_bitsequence_rrr02(empty_texts_bmp,npar,32);\r
free(empty_texts_bmp);\r
empty_texts_bmp = NULL;\r
\r
// stores the texts \r
if (!disable_tc) {\r
- int st = CachedText->size();\r
-\r
- ufwrite(&st, sizeof(int),1,fp);\r
- for (int i = 0; i< CachedText->size(); i++){\r
- st = CachedText->at(i).size();\r
-\r
- ufwrite(&st, sizeof(int),1,fp);\r
-\r
- ufwrite(CachedText->at(i).c_str(),sizeof(char),1+CachedText->at(i).size(),fp);\r
-\r
- };\r
- \r
Text->Save(fp);\r
};\r
\r
int sample_rate_text = 64;\r
// loads the texts\r
if (!XML_Tree->disable_tc){\r
- XML_Tree->CachedText = new vector<string>;\r
- int sst;\r
- int st;\r
- ufread(&sst, sizeof(int),1,fp);\r
- \r
- for (int i=0;i<sst;i++){\r
- ufread(&st, sizeof(int),1,fp);\r
- char* str = (char*) malloc(sizeof(char)*st+1);\r
- ufread(str,sizeof(char),st+1,fp);\r
- string cppstr = str;\r
- XML_Tree->CachedText->push_back(cppstr);\r
- free(str);\r
-\r
- };\r
XML_Tree->Text = TextCollection::Load(fp,sample_rate_text);\r
}\r
else XML_Tree->Text = NULL;\r
// all tree nodes and all text nodes. Assumes that the tree root has preorder 1.\r
int XMLTree::TextXMLId(DocID d) \r
{\r
- int s = EBVector->select1(d+1);\r
+ NULLT_IF(d == NULLT);\r
+ int s = EBVector->select1(d+1);\r
return rank_open(Par, s) + d + 1; // +1 because root has preorder 1\r
- \r
+ \r
}\r
\r
// NodeXMLId(x): returns the preorder of node x in the tree consisting \r
// preorder 0;\r
int XMLTree::NodeXMLId(treeNode x) \r
{\r
+ NULLT_IF(x == NULLT);\r
if (x == Root()) return 1; // root node has preorder 1\r
return rank_open(Par, x) + EBVector->rank1(x-1);\r
}\r
/** The texts in the XML document */\r
TextCollection *Text;\r
\r
- /** The texts in the XML document (cached for faster display) */\r
- vector<string> *CachedText;\r
-\r
// Allows to disable the TextCollection for benchmarkin purposes\r
bool disable_tc;\r
\r
\r
// non const pointer are freed by this method.\r
XMLTree( pb * const par, uint npar, vector<string> * const TN, TagIdMap * const tim, uint *empty_texts_bmp, TagType *tags,\r
- TextCollection * const TC, vector<string> * const CT, bool dis_tc);\r
+ TextCollection * const TC, bool dis_tc);\r
\r
public: \r
/** Data structure destructor */\r
\r
/** GetText(i, j): returns the texts corresponding to documents with\r
* ids i, i+1, ..., j. Texts are separated by '\0' character. */\r
- uchar* GetText(DocID i, DocID j) {\r
- uchar * s = Text->GetText(i, j);\r
- return (s[0] == 1 ? (uchar*)"" : s);\r
- }\r
+ // uchar* GetText(DocID i, DocID j) {\r
+ // uchar * s = Text->GetText(i, j);\r
+ // return (s[0] == 1 ? (uchar*)"" : s);\r
+ //}\r
\r
- uchar* GetCachedText(DocID d) {\r
- uchar * str = (uchar*) calloc(sizeof(char),(CachedText->at(d).size() + 1));\r
- strcpy((char*) str,(const char*) CachedText->at(d).c_str());\r
- return (uchar*) (str);\r
- }\r
- \r
TextCollection *getTextCollection() {\r
return Text;\r
}\r
REGISTER_TAG(TagName,tIdMap,ATTRIBUTE_DATA_CLOSE_TAG);\r
\r
\r
- CachedText = new vector<string>;\r
if (disable_tc)\r
TextBuilder = 0;\r
else \r
empty_texts_aux, // freed by the constructor\r
tags_aux, //freed by the constructor\r
Text,\r
- CachedText,\r
disable_tc);\r
return T; \r
}\r
TextBuilder->InsertText((uchar *) text.c_str());\r
};\r
\r
- CachedText->push_back(text); \r
int n_eta_size = sizeof(uint)*(1+(npar-1)/(8*sizeof(uint)));\r
//see basics.h, recalloc resizes and sets the new area to 0.\r
\r