-#include "basics.h"\r
+#include "common.h"\r
#include "XMLTreeBuilder.h"\r
#include "timings.h"\r
using std::string;\r
STOPTIMER(Parsing);\r
PRINTTIME("Parsing XML Document", Parsing);\r
\r
- if (!disable_tc) {\r
- assert(Text == 0);\r
- assert(TextBuilder != 0);\r
- STARTTIMER();\r
- Text = TextBuilder->InitTextCollection();\r
- delete TextBuilder;\r
- TextBuilder = 0;\r
- STOPTIMER(Building);\r
- PRINTTIME("Building TextCollection", Building);\r
-\r
- }\r
-\r
XMLTree *T = new XMLTree(par_aux,\r
npar,\r
TagName,\r
tIdMap,\r
empty_texts_aux, // freed by the constructor\r
tags_aux, // freed by the constructor\r
- Text,\r
+ TextBuilder, // freed by the constructor\r
disable_tc,\r
text_index_type);\r
tags_aux = 0;\r
int XMLTreeBuilder::NewOpenTag(string tagname)\r
{\r
int i;\r
-\r
// inserts a new opening parentheses in the bit sequence\r
if (sizeof(pb)*8*parArraySize == npar) { // no space left for the new parenthesis\r
- par_aux = (pb *)urealloc(par_aux, sizeof(pb)*2*parArraySize);\r
- parArraySize *= 2;\r
- }\r
\r
- setbit(par_aux,npar,OP); // marks a new opening parenthesis\r
+ // If array is already 1GB, be gentler when resizing:\r
+ if (sizeof(pb)*parArraySize >= 1024*1024*1024)\r
+ parArraySize += (128*1024*1024);\r
+ else\r
+ parArraySize *= 2;\r
+ par_aux = (pb *) urealloc(par_aux, sizeof(pb)*parArraySize);\r
+ };\r
+\r
+ bp_setbit(par_aux,npar,OP); // marks a new opening parenthesis\r
\r
TagIdMapIT tag_id = tIdMap->find(tagname);\r
\r
tagname.compare(ATTRIBUTE_DATA_OPEN_TAG) == 0){\r
};\r
\r
+\r
tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
\r
tags_aux[npar] = i; // inserts the new tag id within the preorder sequence of tags\r
int XMLTreeBuilder::NewClosingTag(string tagname)\r
{\r
int i;\r
-\r
// inserts a new closing parentheses in the bit sequence\r
if (sizeof(pb)*8*parArraySize == npar) { // no space left for the new parenthesis\r
- par_aux = (pb *)urealloc(par_aux, sizeof(pb)*2*parArraySize);\r
- parArraySize *= 2;\r
- }\r
+ // If array is already 1GB, be gentler when resizing:\r
+ if (sizeof(pb)*parArraySize >= 1024*1024*1024)\r
+ parArraySize += (128*1024*1024);\r
+ else\r
+ parArraySize *= 2;\r
+ par_aux = (pb *)urealloc(par_aux, sizeof(pb)*parArraySize);\r
+ };\r
\r
- setbit(par_aux,npar,CP); // marks a new closing parenthesis\r
+ bp_setbit(par_aux,npar,CP); // marks a new closing parenthesis\r
\r
//tagname.insert(0,"/");\r
\r
// else\r
// i = tag_id->second;\r
\r
- tags_aux = (TagType *)urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
+ tags_aux = (TagType *)urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
\r
tags_aux[npar] = CLOSING_TAG_ID; // inserts the new tag id within the preorder sequence of tags\r
\r