Merge branch remove-virtual
[SXSI/XMLTree.git] / xml-tree-builder.cpp
index 0b7effc..a55767c 100644 (file)
@@ -1,5 +1,6 @@
 #include "xml-tree-builder.hpp"
 #include <stdexcept>
+#include <cstdio>
 #include <utility>
 
 using namespace SXSI;
@@ -83,6 +84,7 @@ xml_tree_builder::open_document(bool disable_text_index,
 
   this->disable_text_index = disable_text_index;
   if (!disable_text_index){
+    fprintf(stderr, "Sample rate is %u\n", sample_rate);
     tc_builder = TextCollectionBuilder::create(sample_rate, idx_type);
     text_positions = new bit_vector();
     text_index_type = idx_type;
@@ -94,7 +96,7 @@ void xml_tree_builder::open_tag(std::string tag)
   int32_t id = register_tag(tag);
   tags->push_back(id);
   par->push_back(true);
-  if (!disable_text_index) text_positions->push_back(false);
+  if (!disable_text_index) text_positions->set_le(text_positions->size(), false);
 }
 
 void xml_tree_builder::close_tag(std::string)
@@ -102,7 +104,7 @@ void xml_tree_builder::close_tag(std::string)
   xml_tree::tag_t t = xml_tree::CLOSE_TAG_ID;
   tags->push_back(t);
   par->push_back(false);
-  if (!disable_text_index) text_positions->push_back(false);
+  if (!disable_text_index) text_positions->set_le(text_positions->size(), false);
 }
 
 void xml_tree_builder::text(std::string s)
@@ -110,7 +112,7 @@ void xml_tree_builder::text(std::string s)
   if (!disable_text_index){
     if (s.empty()) s = "\001";
     tc_builder->InsertText((const unsigned char *) s.c_str());
-    text_positions->set(text_positions->size() - 1, true);
+    text_positions->set_le(text_positions->size() - 1, true);
   }
 }