59 for (
unsigned i = 0; i < max_coll; ++i)
62 str.append(to_string(i));
63 str_coll.emplace_back(str);
68 unsigned prefix_len = (unsigned)rand() % 5;
69 for (
unsigned j = 0; j < prefix_len; ++j)
71 char cch = char(
'a' + (
unsigned)rand() % 26);
72 prefix.push_back(cch);
81 const unsigned max_coll = 30000000;
85 std::vector<string> str_coll;
88 cout <<
"Prepare test data" << endl;
89 cout <<
" generation ..." << endl;
92 cout <<
" sort..." << endl;
93 std::sort(str_coll.begin(), str_coll.end());
99 for (
auto str : str_coll)
105 cout <<
" remap-optimize-freeze..." << endl;
111 std::vector<string> str_coll_test1;
113 const unsigned pick_factor = 5;
114 for (
size_t i = 0; i < size_t(str_coll.size()); i+=pick_factor)
116 const string& s = str_coll[i];
117 str_coll_test1.push_back(s);
119 std::random_device rd;
120 std::mt19937 g(rd());
121 std::shuffle(str_coll_test1.begin(), str_coll_test1.end(), g);
124 cout <<
"Run test" << endl;
127 size_t sum_pos4=0, sum_pos32=0;
148 scanner.
bind(str_sv_srt,
true);
150 bm::chrono_taker tt(cout,
"bm::sparse_vector_scanner<>::bfind_eq_str() [4] ", 1);
151 for (
unsigned i = 0; i < unsigned(str_coll_test1.size()); ++i)
153 const string& s = str_coll_test1[i];
157 cerr <<
"String bfind_eq_str() failure!" << endl;
167 scanner.
bind(str_sv_srt,
true);
169 bm::chrono_taker tt(cout,
"bm::sparse_vector_scanner<>::bfind_eq_str() [32] ", 1);
170 for (
unsigned i = 0; i < unsigned(str_coll_test1.size()); ++i)
172 const string& s = str_coll_test1[i];
176 cerr <<
"String bfind_eq_str() failure!" << endl;
183 assert(sum_pos4 == sum_pos32);
186 catch(std::exception& ex)
188 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
Algorithms for bm::sparse_vector.
string sparse vector based on bit-transposed matrix
Timing utilities for benchmarking (internal).
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
Utility class to collect performance measurements and statistics.
algorithms for sparse_vector scan/search
void bind(const SV &sv, bool sorted)
bind sparse vector for all searches
bool bfind_eq_str(const SV &sv, const value_type *str, size_type &pos)
binary find first sparse vector element (string).
succinct sparse vector for strings with compression using bit-slicing ( transposition) method
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename str_sparse_vector< CharType, BV, STR_SIZE >::statistics *stat=0)
run memory optimization for all vector planes
void freeze()
Turn sparse vector into immutable mode Read-only (immutable) vector uses less memory and allows faste...
void remap()
Build remapping profile and re-load content to save memory.
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster,...
bvector_type::size_type size_type
bm::str_sparse_vector< char, bvector_type, 32 > str_sv_type
static void GenerateTestStrCollection(std::vector< string > &str_coll, unsigned max_coll)