From 46dd7565a6c8d813459b81cf2b19446db1b51010 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 28 Jan 2009 02:43:32 +0000 Subject: [PATCH] - Added an option to disable the TextCollection. - Plugged some memleaks in CloseDocument() git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@83 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- XMLTree.cpp | 21 +++++++++++++++++---- XMLTree.h | 9 ++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/XMLTree.cpp b/XMLTree.cpp index fe01896..ecc9a27 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -570,7 +570,7 @@ treeNode XMLTree::ParentNode(DocID d) // OpenDocument(empty_texts): it starts the construction of the data structure for // the XML document. Parameter empty_texts indicates whether we index empty texts // in document or not. Returns a non-zero value upon success, NULLT in case of error. -int XMLTree::OpenDocument(bool empty_texts, int sample_rate_text) +int XMLTree::OpenDocument(bool empty_texts, int sample_rate_text,bool dtc) { initialized = true; finished = false; @@ -578,7 +578,8 @@ int XMLTree::OpenDocument(bool empty_texts, int sample_rate_text) npar = 0; parArraySize = 1; ntagnames = 2; - + disable_tc = dtc; + indexing_empty_texts = empty_texts; par_aux = (pb *)malloc(sizeof(pb)*parArraySize); @@ -666,11 +667,18 @@ int XMLTree::CloseDocument() delete pmb; delete ssb; // makes the text collection static - Text->MakeStatic(); + if (!disable_tc) + Text->MakeStatic(); // creates the data structure marking the non-empty texts (just in the case it is necessary) - if (!indexing_empty_texts) + if (!indexing_empty_texts) { EBVector = new static_bitsequence_rrr02((uint *)empty_texts_aux,(ulong)npar,(uint)32); + free (empty_texts_aux); + empty_texts_aux = NULL; + } + + free(tags_aux); + tags_aux = NULL; finished = true; @@ -809,6 +817,11 @@ int XMLTree::NewText(unsigned char *s) return NULLT; } + if (disable_tc) { + XMLTree::NewEmptyText(); + return 1; + }; + if (!indexing_empty_texts) { empty_texts_aux = (unsigned int *)realloc(empty_texts_aux, sizeof(pb)*(1+(npar-1)/(8*sizeof(pb)))); if (!empty_texts_aux) { diff --git a/XMLTree.h b/XMLTree.h index cc5f089..c054b01 100644 --- a/XMLTree.h +++ b/XMLTree.h @@ -91,6 +91,7 @@ class XMLTree { int ntagnames; unsigned int *empty_texts_aux; bool found_attributes; + bool disable_tc; public: @@ -210,14 +211,16 @@ public: /** ParentNode(d): returns the parent node of document identifier d. */ treeNode ParentNode(DocID d); - /** OpenDocument(empty_texts,sample_rate_text): initilizes the construction + /** OpenDocument(empty_texts,sample_rate_text,dtc): initilizes the construction * of the data structure for the XML document. Parameter empty_texts * indicates whether we index empty texts in document or not. Parameter * sample_rate_text indicates the sampling rate for the text searching data * structures (small values get faster searching but a bigger space - * requirement). Returns a non-zero value upon success, NULLT in case of + * requirement). dtc disable the use of the TextCollection + * (i.e. everything is considered an empty text *) + * Returns a non-zero value upon success, NULLT in case of * error. */ - int OpenDocument(bool empty_texts, int sample_rate_text); + int OpenDocument(bool empty_texts, int sample_rate_text, bool dtc); /** CloseDocument(): finishes the construction of the data structure for * the XML document. Tree and tags are represented in the final form, -- 2.17.1