return dest;\r
}\r
\r
+void XMLTree::print_stats() {\r
+ uint total_space = Tags->size()+sizeof(static_sequence*);\r
+ total_space += sizeof(uint*)+sizeof(uint)*(2+uint_len(tags_blen,tags_len));\r
+ cout << "Space usage for XMLTree:" << endl\r
+ << " - tags static_sequence: " << Tags->size()+sizeof(static_sequence*) << endl\r
+ << " - tags access array: " << sizeof(uint*)+sizeof(uint)*(2+uint_len(tags_blen,tags_len)) << endl\r
+ << " ... add Diego structures ... " << endl\r
+ << " *total* " << total_space << endl;\r
+}\r
+\r
// Save: saves XML tree data structure to file. \r
void XMLTree::Save(unsigned char *filename) \r
{\r
\r
fclose(fp);\r
\r
- std::cerr << "Tree part is " << s_tree/1024 << " Kbytes,\n"\r
+ /*std::cerr << "Tree part is " << s_tree/1024 << " Kbytes,\n"\r
<< "with node->tagid part " << XML_Tree->Tags->size()/1024+(uint_len(XML_Tree->tags_blen,XML_Tree->tags_len)*sizeof(uint))/1024 << "Kbytes \n"\r
<< "size of Tag part : " << XML_Tree->Tags->length () << " elements\n"\r
<< "sizof(unsigned int)* " << XML_Tree->Tags->length () << " = " << \r
sizeof(unsigned int) * XML_Tree->Tags->length () / 1024 << " Kbytes\n"\r
<< "Tag part is " << s_tags/1024 << " Kbytes,\n"\r
- << "Text collection is " << s_text/1024 << " Kbytes \n";\r
+ << "Text collection is " << s_text/1024 << " Kbytes \n";*/\r
+ XML_Tree->print_stats();\r
return XML_Tree;\r
}\r
\r
\r
// If we found an attribute then "<@>" is present in the tree\r
// if we didn't then it is not. "<$>" is never present in the tree\r
+ uint max_tag = 0;\r
+ for(uint i=0;i<(uint)npar-1;i++)\r
+ max_tag = max(max_tag,tags_aux[i]);\r
+ max_tag++;\r
int ntagsize = found_attributes ? 2*ntagnames-1 : 2*ntagnames - 2;\r
+ tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
+ tags_aux[npar++] = max_tag;\r
\r
static_bitsequence_builder * bmb = new static_bitsequence_builder_brw32(20);\r
alphabet_mapper *am = new alphabet_mapper_none();\r
- wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar-1,am);\r
- Tags = new static_sequence_wvtree((uint*)tags_aux,npar-1,wc ,bmb, am);\r
+ wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar,am);\r
+ Tags = new static_sequence_wvtree((uint*)tags_aux,npar,wc ,bmb, am);\r
//Tags = new static_sequence_gmr((uint *) tags_aux, (uint) npar-1,ntagsize, bmb, ssb);\r
- uint max_tag = 0;\r
- for(uint i=0;i<(uint)npar-1;i++)\r
- max_tag = max(max_tag,tags_aux[i]);\r
tags_blen = bits(max_tag);\r
- tags_len = (uint)npar-1;\r
+ tags_len = (uint)npar;\r
tags_fix = new uint[uint_len(tags_blen,tags_len)];\r
for(uint i=0;i<(uint)npar-1;i++)\r
set_field(tags_fix,tags_blen,i,tags_aux[i]);\r
tags_aux = NULL;\r
\r
finished = true;\r
+ print_stats();\r
\r
return 1; // indicates success in the inicialization\r
}\r
// this should be changed for more efficient processing\r
for (i=0; i<ntagnames; i++)\r
if (strcmp((const char *)tagname,(const char *)TagName[i])==0) break; \r
- if (i==ntagnames) return (TagType)NULLT; // tagname does not exists in the table\r
+ if (i==ntagnames) return ntagnames; //(TagType)NULLT; // tagname does not exists in the table\r
else return i;\r
}\r
\r