From 1413ae2197d87e87571c9d8d6fc9f20f691fcea3 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 11 May 2009 05:37:25 +0000 Subject: [PATCH] Removed the naive text interface git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@383 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- XMLTree.cpp | 36 ++++++------------------------------ XMLTree.h | 19 +++++-------------- XMLTreeBuilder.cpp | 3 --- darray.c | 2 +- 4 files changed, 12 insertions(+), 48 deletions(-) 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); } diff --git a/XMLTree.h b/XMLTree.h index 6a722f9..275b9bc 100644 --- a/XMLTree.h +++ b/XMLTree.h @@ -118,9 +118,6 @@ class XMLTree { /** The texts in the XML document */ TextCollection *Text; - /** The texts in the XML document (cached for faster display) */ - vector *CachedText; - // Allows to disable the TextCollection for benchmarkin purposes bool disable_tc; @@ -130,7 +127,7 @@ class XMLTree { // non const pointer are freed by this method. 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); public: /** Data structure destructor */ @@ -396,17 +393,11 @@ public: /** GetText(i, j): returns the texts corresponding to documents with * ids i, i+1, ..., j. Texts are separated by '\0' character. */ - uchar* GetText(DocID i, DocID j) { - uchar * s = Text->GetText(i, j); - return (s[0] == 1 ? (uchar*)"" : s); - } + // uchar* GetText(DocID i, DocID j) { + // uchar * s = Text->GetText(i, j); + // return (s[0] == 1 ? (uchar*)"" : s); + //} - uchar* GetCachedText(DocID d) { - uchar * str = (uchar*) calloc(sizeof(char),(CachedText->at(d).size() + 1)); - strcpy((char*) str,(const char*) CachedText->at(d).c_str()); - return (uchar*) (str); - } - TextCollection *getTextCollection() { return Text; } diff --git a/XMLTreeBuilder.cpp b/XMLTreeBuilder.cpp index 138db9b..9c0fc6a 100644 --- a/XMLTreeBuilder.cpp +++ b/XMLTreeBuilder.cpp @@ -33,7 +33,6 @@ int XMLTreeBuilder::OpenDocument(bool empty_texts, int sample_rate_text, bool dt REGISTER_TAG(TagName,tIdMap,ATTRIBUTE_DATA_CLOSE_TAG); - CachedText = new vector; if (disable_tc) TextBuilder = 0; else @@ -71,7 +70,6 @@ XMLTree *XMLTreeBuilder::CloseDocument() empty_texts_aux, // freed by the constructor tags_aux, //freed by the constructor Text, - CachedText, disable_tc); return T; } @@ -163,7 +161,6 @@ int XMLTreeBuilder::NewText(string text) TextBuilder->InsertText((uchar *) text.c_str()); }; - CachedText->push_back(text); int n_eta_size = sizeof(uint)*(1+(npar-1)/(8*sizeof(uint))); //see basics.h, recalloc resizes and sets the new area to 0. diff --git a/darray.c b/darray.c index 7d302c4..3359ed3 100644 --- a/darray.c +++ b/darray.c @@ -7,7 +7,7 @@ //typedef unsigned int dword; //typedef dword pb; -#define logD 5 +//#define logD 5 #define PBS (sizeof(pb)*8) #define D (1<