\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