Example of how to use bm::str_sparse_vector<> - succinct container for bit-transposed string collections for deserialization of only select elements from the serialized BLOB.
Example of how to use bm::str_sparse_vector<> - succinct container for bit-transposed string collections for deserialization of only select elements from the serialized BLOB
#include <iostream>
#include <string>
#include <vector>
#include <assert.h>
using namespace std;
{
try
{
{
{
for (unsigned i = 0; i < 100000; ++i)
{
bi = "ATGC";
bi = "GCTA";
bi = "GCAA";
bi = "TATA";
}
}
}
cout <<
"Used memory: " << st.
memory_used << std::endl;
const unsigned char* buf = sv_lay.
buf();
cout <<
"Serialized size = " << sv_lay.
size() << endl;
{
char s1[16]; char s2[16]; char s3[16];
{
str_sv1.
get(j, s1,
sizeof(s1));
str_sv2.
get(j, s2,
sizeof(s2));
str_sv3.
get(j, s3,
sizeof(s3));
int cmp;
cmp = ::strcmp(s1, s2);
assert(cmp==0);
cmp = ::strcmp(s1, s3);
assert(cmp==0);
}
cout << "Gather deserialization check OK" << endl;
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
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
Bitvector Bit-vector container with runtime compression of bits.
bvector< Alloc > & set_range(size_type left, size_type right, bool value=true)
Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's siz...
sparse vector de-serializer
void deserialize_range(SV &sv, const unsigned char *buf, size_type from, size_type to)
void deserialize(SV &sv, const unsigned char *buf)
void set_bookmarks(bool enable, unsigned bm_interval=256)
Add skip-markers for faster range deserialization.
void serialize(const SV &sv, sparse_vector_serial_layout< SV > &sv_layout)
Serialize sparse vector into a memory buffer(s) structure.
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.
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster,...
void calc_stat(struct str_sparse_vector< CharType, BV, MAX_STR_SIZE >::statistics *st) const BMNOEXCEPT
Calculates memory statistics.
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
size_type get(size_type idx, value_type *str, size_type buf_size) const BMNOEXCEPT
get specified element
bm::str_sparse_vector< char, bvector_type, 32 > str_sv_type
size_t memory_used
memory usage for all blocks and service tables
layout class for serialization buffer structure
size_t size() const
return current serialized size
const unsigned char * buf() const
Return serialization buffer pointer.