Exmaple demonstrates bitvector serialization/deserialization and set-operations on searialized BLOBs
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
static
{
{
if ((rand() % 10))
{
}
}
}
{
try
{
cout <<
"bv1 count = " << bv1.
count() << endl;
cout <<
"bv2 count = " << bv2.
count() << endl;
bvs.set_compression_level(4);
bvs.serialize(bv2, sbuf2, &st2);
std::vector<unsigned char> vect1;
std::vector<unsigned char> vect2;
vect1.resize(sbuf1.size());
vect2.resize(sbuf2.size());
::memcpy(vect1.data(), sbuf1.buf(), sbuf1.size());
::memcpy(vect2.data(), sbuf2.buf(), sbuf2.size());
cout << "bv4 count = " << bv4.count() << endl;
bool eq = bv1.
equal(bv4);
if (!eq)
{
cerr << "Logical error detected!" << endl;
return 1;
}
else
cout << "bv4 is equal to bv1" << endl;
auto cnt_sub =
cout << "minus count = " << cnt_sub << endl;
auto bv5_cnt = bv5.count();
cout << "bv5 count = " << bv5_cnt << endl;
if (cnt_sub != bv5_cnt)
{
cerr << "Logical error!" << endl;
return 1;
}
}
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 / compression of bvector<>. Set theoretical operations on compressed BLOBs.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
bool equal(const bvector< Alloc > &bvect) const BMNOEXCEPT
Equal comparison with an agr bit-vector.
size_type count() const BMNOEXCEPT
population count (count of ON bits)
bvector< Alloc > & set(size_type n, bool val=true)
Sets bit n if val is true, clears bit n if val is false.
void optimize(bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
Optimize memory bitvector's memory allocation.
Deserializer, performs logical operations between bit-vector and serialized bit-vector.
size_type deserialize(bvector_type &bv, const unsigned char *buf, set_operation op, bool exit_on_one=false)
Deserialize bvector using buffer as set operation argument.
Bit-vector serialization class.
size_type serialize(const BV &bv, unsigned char *buf, size_t buf_size)
Bitvector serialization into memory block.
size_t deserialize(BV &bv, const unsigned char *buf, bm::word_t *temp_block=0, const bm::bv_ref_vector< BV > *ref_vect=0)
Bitvector deserialization from a memory BLOB.
static void fill_bvector(bm::bvector<> *bv)
Statistical information about bitset's memory allocation details.