Removed the naive text interface
[SXSI/XMLTree.git] / XMLTree.cpp
index 61f6a4d..f03360e 100644 (file)
@@ -26,7 +26,7 @@ inline int node2tagpos(treeNode x)
 \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
@@ -58,7 +58,7 @@ XMLTree::XMLTree( pb * const par, uint npar,  vector<string> * const TN,  TagIdM
     \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
@@ -139,18 +139,6 @@ void XMLTree::Save(int fd)
     \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
@@ -228,20 +216,6 @@ XMLTree *XMLTree::Load(int fd)
     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
@@ -640,9 +614,10 @@ DocID XMLTree::MyText(treeNode x)
 // 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
@@ -650,6 +625,7 @@ int XMLTree::TextXMLId(DocID d)
 // 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