X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=f03360ee1b9dd67d439fa5d6e479d91727bbdfd0;hb=1413ae2197d87e87571c9d8d6fc9f20f691fcea3;hp=61f6a4d30b0223a246f2656838f40cc1240c7546;hpb=fdf29cca5a2df608373ffbeb3a4155876a55df2c;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index 61f6a4d..f03360e 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -26,7 +26,7 @@ inline int node2tagpos(treeNode x) XMLTree::XMLTree( pb * const par, uint npar, vector * const TN, TagIdMap * const tim, uint *empty_texts_bmp, TagType *tags, - TextCollection * const TC, vector * const CT, bool dis_tc) + TextCollection * const TC, bool dis_tc) { // creates the data structure for the tree topology @@ -58,7 +58,7 @@ XMLTree::XMLTree( pb * const par, uint npar, vector * const TN, TagIdM Text = (TextCollection*) TC; - CachedText = (vector*) CT; + EBVector = new static_bitsequence_rrr02(empty_texts_bmp,npar,32); free(empty_texts_bmp); empty_texts_bmp = NULL; @@ -139,18 +139,6 @@ void XMLTree::Save(int fd) // stores the texts if (!disable_tc) { - int st = CachedText->size(); - - ufwrite(&st, sizeof(int),1,fp); - for (int i = 0; i< CachedText->size(); i++){ - st = CachedText->at(i).size(); - - ufwrite(&st, sizeof(int),1,fp); - - ufwrite(CachedText->at(i).c_str(),sizeof(char),1+CachedText->at(i).size(),fp); - - }; - Text->Save(fp); }; @@ -228,20 +216,6 @@ XMLTree *XMLTree::Load(int fd) int sample_rate_text = 64; // loads the texts if (!XML_Tree->disable_tc){ - XML_Tree->CachedText = new vector; - int sst; - int st; - ufread(&sst, sizeof(int),1,fp); - - for (int i=0;iCachedText->push_back(cppstr); - free(str); - - }; XML_Tree->Text = TextCollection::Load(fp,sample_rate_text); } else XML_Tree->Text = NULL; @@ -640,9 +614,10 @@ DocID XMLTree::MyText(treeNode x) // all tree nodes and all text nodes. Assumes that the tree root has preorder 1. int XMLTree::TextXMLId(DocID d) { - int s = EBVector->select1(d+1); + NULLT_IF(d == NULLT); + int s = EBVector->select1(d+1); return rank_open(Par, s) + d + 1; // +1 because root has preorder 1 - + } // NodeXMLId(x): returns the preorder of node x in the tree consisting @@ -650,6 +625,7 @@ int XMLTree::TextXMLId(DocID d) // preorder 0; int XMLTree::NodeXMLId(treeNode x) { + NULLT_IF(x == NULLT); if (x == Root()) return 1; // root node has preorder 1 return rank_open(Par, x) + EBVector->rank1(x-1); }