66 const unsigned max_coll = 50000;
70 for (
unsigned i = 10; i < max_coll; i += (unsigned)rand() % 3)
73 str_vec.emplace_back(str);
78 std::random_device rd;
80 std::shuffle(str_vec.begin(), str_vec.end(), g);
90 vector<string> str_vec;
92 std::sort(str_vec.begin(), str_vec.end());
101 str_sv_type::back_insert_iterator bi =
103 for (
auto str : str_vec)
109 size_t str_size = str.size() +
sizeof(str);
110 vect_size += str_size;
122 cout <<
"STL vector<string> approx.memory consumption:"
123 << vect_size << endl;
128 str_sv_type::statistics st;
131 cout <<
"Used memory: " << st.memory_used << std::endl;
145 cout <<
"Used memory after remap and optimization: "
160 str_sv_type::back_insert_iterator bi =
163 for (
auto str : str_vec)
175 assert(str_sv1.
is_ro());
176 bool eq = str_sv1.
equal(str_sv);
177 assert(eq); (void)eq;
180 cout <<
"Used memory after remap / optimization / freeze: "
195 str_sv_type::back_insert_iterator bi =
197 for (
auto str : str_vec)
206 cout <<
"size2=" << str_sv2.
size() << endl;
217 std::string fname =
"test.sv";
223 std::ofstream fout(fname.c_str(), std::ios::binary);
228 const char* buf = (
char*)sv_lay.
buf();
229 fout.write(buf, (
unsigned)sv_lay.
size());
236 cout <<
"Saved size: " << sv_lay.
size() << endl;
240 catch(std::exception& ex)
242 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
Serialization for sparse_vector<>.
string sparse vector based on bit-transposed matrix
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
succinct sparse vector for strings with compression using bit-slicing ( transposition) method
bool is_ro() const BMNOEXCEPT
Returns true if vector is read-only.
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 calc_stat(struct str_sparse_vector< CharType, BV, STR_SIZE >::statistics *st) const BMNOEXCEPT
Calculates memory statistics.
bool equal(const str_sparse_vector< CharType, BV, STR_SIZE > &sv, bm::null_support null_able=bm::use_null) const BMNOEXCEPT
check if another sparse vector has the same content and size
void remap_from(const str_sparse_vector &str_sv, octet_freq_matrix_type *omatrix=0)
Build remapping profile and load content from another sparse vector Remapped vector likely saves memo...
size_type size() const
return size of the vector
void freeze()
Turn sparse vector into immutable mode Read-only (immutable) vector uses less memory and allows faste...
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster,...
void sparse_vector_serialize(const SV &sv, sparse_vector_serial_layout< SV > &sv_layout, bm::word_t *temp_block=0)
Serialize sparse vector into a memory buffer(s) structure.
@ COPY_RTABLES
copy remap tables only (without data)
bm::str_sparse_vector< char, bvector_type, 32 > str_sv_type
static void generate_string_set(vector< string > &str_vec)
layout class for serialization buffer structure
const unsigned char * buf() const BMNOEXCEPT
Return serialization buffer pointer.
size_t size() const BMNOEXCEPT
return current serialized size