Removed the naive text interface
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Mon, 11 May 2009 05:37:25 +0000 (05:37 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Mon, 11 May 2009 05:37:25 +0000 (05:37 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@383 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

XMLTree.cpp
XMLTree.h
XMLTreeBuilder.cpp
darray.c

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
index 6a722f9..275b9bc 100644 (file)
--- a/XMLTree.h
+++ b/XMLTree.h
@@ -118,9 +118,6 @@ class XMLTree {
    /** 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
@@ -130,7 +127,7 @@ class XMLTree {
 \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
@@ -396,17 +393,11 @@ public:
 \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
index 138db9b..9c0fc6a 100644 (file)
@@ -33,7 +33,6 @@ int XMLTreeBuilder::OpenDocument(bool empty_texts, int sample_rate_text, bool dt
     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
@@ -71,7 +70,6 @@ XMLTree *XMLTreeBuilder::CloseDocument()
                             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
@@ -163,7 +161,6 @@ int XMLTreeBuilder::NewText(string text)
        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
index 7d302c4..3359ed3 100644 (file)
--- a/darray.c
+++ b/darray.c
@@ -7,7 +7,7 @@
 //typedef unsigned int dword;\r
 \r
 //typedef dword pb;\r
-#define logD 5\r
+//#define logD 5\r
 \r
 #define PBS (sizeof(pb)*8)\r
 #define D (1<<logD)\r