X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=92360a432535065f46769245eadee9f98515c005;hb=a9846746dc7a55764591fcc273fd48c6049df962;hp=7d0c5e3c4d47aeffbaef88030f4a7e7d0e2a3293;hpb=efe894650813a19a0e1408eb5807e59f037afc3b;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index 7d0c5e3..92360a4 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -101,7 +101,7 @@ XMLTree *XMLTree::Load(unsigned char *filename, int sample_rate_text) if (!(XML_Tree->indexing_empty_texts)) XML_Tree->EBVector = static_bitsequence_rrr02::load(fp); // loads the tags - XML_Tree->Tags = static_sequence_wvtree::load(fp); + XML_Tree->Tags = static_sequence::load(fp); // loads the texts XML_Tree->Text->Load(fp,sample_rate_text); @@ -126,16 +126,16 @@ XMLTree::~XMLTree() free(TagName); if (!indexing_empty_texts) { - EBVector->~static_bitsequence_rrr02(); + //EBVector->~static_bitsequence_rrr02(); delete EBVector; EBVector = NULL; } - Tags->~static_sequence_wvtree(); + //Tags->~static_sequence_wvtree(); delete Tags; Tags = NULL; - Text->~TextCollection(); + //Text->~TextCollection(); delete Text; Text = NULL; @@ -571,11 +571,12 @@ int XMLTree::OpenDocument(bool empty_texts, int sample_rate_text) initialized = true; finished = false; npar = 0; - ntagnames = 0; - + parArraySize = 1; + ntagnames = 0; + indexing_empty_texts = empty_texts; - par_aux = (pb *)malloc(sizeof(pb)); + par_aux = (pb *)malloc(sizeof(pb)*parArraySize); if (!par_aux) { fprintf(stderr, "Error: not enough memory\n"); return NULLT; @@ -621,14 +622,18 @@ int XMLTree::CloseDocument() } // creates the data structure for the tree topology - Par = (bp *)malloc(sizeof(bp)); + Par = (bp *)malloc(sizeof(bp)); bp_construct(Par, npar, par_aux, OPT_DEGREE|0); // creates structure for tags - alphabet_mapper * am = new alphabet_mapper_none(); - static_bitsequence_builder * bmb = new static_bitsequence_builder_rrr02(32); - wt_coder * wtc = new wt_coder_huff((uint *)tags_aux,npar-1,am); - Tags = new static_sequence_wvtree((uint *) tags_aux, (uint) npar-1, wtc, bmb, am); + static_bitsequence_builder * bmb = new static_bitsequence_builder_brw32(20); + static_permutation_builder * pmb = new static_permutation_builder_mrrr(PERM_SAMPLE, bmb); + static_sequence_builder * ssb = new static_sequence_builder_gmr_chunk(bmb, pmb); + Tags = new static_sequence_gmr((uint *) tags_aux, (uint) npar-1,2*ntagnames, bmb, ssb); + + delete bmb; + delete pmb; + delete ssb; // makes the text collection static Text->MakeStatic(); @@ -655,7 +660,11 @@ int XMLTree::NewOpenTag(unsigned char *tagname) } // inserts a new opening parentheses in the bit sequence - par_aux = (pb *)realloc(par_aux, sizeof(pb)*(1+npar/(8*sizeof(pb)))); + if (sizeof(pb)*8*parArraySize == npar) { // no space left for the new parenthesis + par_aux = (pb *)realloc(par_aux, sizeof(pb)*2*parArraySize); + parArraySize *= 2; + } + if (!par_aux) { fprintf(stderr, "Error: not enough memory\n"); return NULLT; @@ -708,7 +717,11 @@ int XMLTree::NewClosingTag(unsigned char *tagname) } // inserts a new closing parentheses in the bit sequence - par_aux = (pb *)realloc(par_aux, sizeof(pb)*(1+npar/(8*sizeof(pb)))); + if (sizeof(pb)*8*parArraySize == npar) { // no space left for the new parenthesis + par_aux = (pb *)realloc(par_aux, sizeof(pb)*2*parArraySize); + parArraySize *= 2; + } + if (!par_aux) { fprintf(stderr, "Error: not enough memory\n"); return NULLT;