X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=057a1178245fcd98fb18cc7179e20c1f4fc328bd;hb=4e6e8f179979f24c8f77e11eb8f6cc3d609a52d4;hp=e17c89d90358731f2cbad205b9c5a4534f96af76;hpb=d6ecf291b7dd99ec191daa090a2ff3dac08f8150;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index e17c89d..057a117 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -67,6 +67,16 @@ inline void * umalloc(size_t size){ return dest; } +void XMLTree::print_stats() { + uint total_space = Tags->size()+sizeof(static_sequence*); + total_space += sizeof(uint*)+sizeof(uint)*(2+uint_len(tags_blen,tags_len)); + cout << "Space usage for XMLTree:" << endl + << " - tags static_sequence: " << Tags->size()+sizeof(static_sequence*) << endl + << " - tags access array: " << sizeof(uint*)+sizeof(uint)*(2+uint_len(tags_blen,tags_len)) << endl + << " ... add Diego structures ... " << endl + << " *total* " << total_space << endl; +} + // Save: saves XML tree data structure to file. void XMLTree::Save(unsigned char *filename) { @@ -230,13 +240,14 @@ XMLTree *XMLTree::Load(unsigned char *filename, int sample_rate_text) fclose(fp); - std::cerr << "Tree part is " << s_tree/1024 << " Kbytes,\n" + /*std::cerr << "Tree part is " << s_tree/1024 << " Kbytes,\n" << "with node->tagid part " << XML_Tree->Tags->size()/1024+(uint_len(XML_Tree->tags_blen,XML_Tree->tags_len)*sizeof(uint))/1024 << "Kbytes \n" << "size of Tag part : " << XML_Tree->Tags->length () << " elements\n" << "sizof(unsigned int)* " << XML_Tree->Tags->length () << " = " << sizeof(unsigned int) * XML_Tree->Tags->length () / 1024 << " Kbytes\n" << "Tag part is " << s_tags/1024 << " Kbytes,\n" - << "Text collection is " << s_text/1024 << " Kbytes \n"; + << "Text collection is " << s_text/1024 << " Kbytes \n";*/ + XML_Tree->print_stats(); return XML_Tree; } @@ -851,18 +862,21 @@ int XMLTree::CloseDocument() // If we found an attribute then "<@>" is present in the tree // if we didn't then it is not. "<$>" is never present in the tree + uint max_tag = 0; + for(uint i=0;i<(uint)npar-1;i++) + max_tag = max(max_tag,tags_aux[i]); + max_tag++; int ntagsize = found_attributes ? 2*ntagnames-1 : 2*ntagnames - 2; + tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1)); + tags_aux[npar++] = max_tag; static_bitsequence_builder * bmb = new static_bitsequence_builder_brw32(20); alphabet_mapper *am = new alphabet_mapper_none(); - wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar-1,am); - Tags = new static_sequence_wvtree((uint*)tags_aux,npar-1,wc ,bmb, am); + wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar,am); + Tags = new static_sequence_wvtree((uint*)tags_aux,npar,wc ,bmb, am); //Tags = new static_sequence_gmr((uint *) tags_aux, (uint) npar-1,ntagsize, bmb, ssb); - uint max_tag = 0; - for(uint i=0;i<(uint)npar-1;i++) - max_tag = max(max_tag,tags_aux[i]); tags_blen = bits(max_tag); - tags_len = (uint)npar-1; + tags_len = (uint)npar; tags_fix = new uint[uint_len(tags_blen,tags_len)]; for(uint i=0;i<(uint)npar-1;i++) set_field(tags_fix,tags_blen,i,tags_aux[i]); @@ -887,6 +901,7 @@ int XMLTree::CloseDocument() tags_aux = NULL; finished = true; + print_stats(); return 1; // indicates success in the inicialization } @@ -1049,7 +1064,7 @@ TagType XMLTree::GetTagId(unsigned char *tagname) // this should be changed for more efficient processing for (i=0; i