64 const unsigned max_coll = 50000;
68 for (
unsigned i = 10; i < max_coll; i += rand() % 3)
71 str_vec.emplace_back(str);
76 std::random_device rd;
78 std::shuffle(str_vec.begin(), str_vec.end(), g);
88 vector<string> str_vec;
90 std::sort(str_vec.begin(), str_vec.end());
101 for (
auto str : str_vec)
107 size_t str_size = str.size() +
sizeof(str);
108 vect_size += str_size;
120 cout <<
"STL vector<string> approx.memory consumption:" 121 << vect_size << endl;
129 cout <<
"Used memory: " << st.
memory_used << std::endl;
143 cout <<
"Used memory after remap and optimization: " 151 std::string fname =
"test.sv";
157 std::ofstream fout(fname.c_str(), std::ios::binary);
162 const char* buf = (
char*)sv_lay.
buf();
163 fout.write(buf, (
unsigned)sv_lay.
size());
170 cout <<
"Saved size: " << sv_lay.
size() << endl;
174 catch(std::exception& ex)
176 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
size_t size() const
return current serialized size
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename str_sparse_vector< CharType, BV, MAX_STR_SIZE >::statistics *stat=0)
run memory optimization for all vector plains
string sparse vector based on bit-transposed matrix
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.
void flush()
flush the accumulated buffer
#define BM_DECLARE_TEMP_BLOCK(x)
size_t memory_used
memory usage for all blocks and service tables
void calc_stat(struct str_sparse_vector< CharType, BV, MAX_STR_SIZE >::statistics *st) const
Calculates memory statistics.
Back insert iterator implements buffered insert, faster than generic access assignment.
sparse vector for strings with compression using bit transposition method
void remap_from(const str_sparse_vector &str_sv)
Build remapping profile and load content from another sparse vector.
Serialization for sparse_vector<>
static void generate_string_set(vector< string > &str_vec)
layout class for serialization buffer structure
const unsigned char * buf() const
Return serialization buffer pointer.
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster...
bm::str_sparse_vector< char, bvector_type, 32 > str_sv_type