64 for (
unsigned i = 0; i < 128000; ++i)
78 const unsigned char* buf = sv_lay.
buf();
79 size_t buf_size = sv_lay.
size();
80 cout << buf_size << endl;
82 vector<unsigned char> tmp_buf(buf_size);
83 ::memcpy(&tmp_buf[0], buf, buf_size);
88 cerr <<
"De-Serialization error!" << endl;
93 cerr <<
"Error! Please report a bug to BitMagic project support." << endl;
113 for (
unsigned i = 0; i < 128000; i+=2)
115 for (
unsigned i = 128000; i < 128000*4; i+=256)
135 const unsigned char* buf = sv_lay0.
data();
136 size_t sz = sv_lay0.
size();
137 cout <<
"XOR compression enabled size=" << sz << endl;
144 assert(sv3.
equal(sv1));
166 bool eq = sv3.
equal(sv4);
167 assert(eq); (void)eq;
172 sparse_vector_u32::statistics st3, st4;
176 cout <<
"RW vector mem=" << st3.memory_used << endl;
177 cout <<
"RO vector mem=" << st4.memory_used << endl;
191 buf = sv_lay0.
data();
193 cout <<
"XOR compression disabled size=" << sz << endl;
200 assert(sv3.
equal(sv1));
209 cout <<
"Demo 1" << endl;
212 cout <<
"Demo 2" << endl;
215 catch(std::exception& ex)
217 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
#define BM_DECLARE_TEMP_BLOCK(x)
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
Serialization for sparse_vector<>.
pre-processor un-defines to avoid global space pollution (internal)
sparse vector de-serializer
void deserialize(SV &sv, const unsigned char *buf, bool clear_sv=true)
void set_finalization(bm::finalization is_final)
Set deserialization finalization to force deserialized vectors into READONLY (or READWRITE) mode.
void serialize(const SV &sv, sparse_vector_serial_layout< SV > &sv_layout)
Serialize sparse vector into a memory buffer(s) structure.
bool is_xor_ref() const BMNOEXCEPT
Returns the XOR reference compression status (enabled/disabled).
void disable_xor_compression() BMNOEXCEPT
Disable XOR compression on serialization.
void enable_xor_compression() BMNOEXCEPT
Enable XOR compression on vector serialization.
succinct sparse vector with runtime compression using bit-slicing / transposition method
bool equal(const sparse_vector< Val, BV > &sv, bm::null_support null_able=bm::use_null) const BMNOEXCEPT
check if another sparse vector has the same content and size
void push_back(value_type v)
push value back into vector
void set(size_type idx, value_type v)
set specified element with bounds checking and automatic resize
void calc_stat(struct sparse_vector< Val, BV >::statistics *st) const BMNOEXCEPT
Calculates memory statistics.
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 sparse_vector< Val, BV >::statistics *stat=0)
run memory optimization for all vector planes
@ use_null
support "non-assigned" or "NULL" logic
@ READONLY
immutable (read-only object)
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.
int sparse_vector_deserialize(SV &sv, const unsigned char *buf, bm::word_t *temp_block=0)
Deserialize sparse vector.
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
const unsigned char * data() const BMNOEXCEPT
Return serialization buffer pointer.
bm::sparse_vector< int, bm::bvector<> > sparse_vector_i32
static void SDemo2()
Demo 2.
bm::sparse_vector_serializer< sparse_vector_u32 > sv_serializer_type
bm::sparse_vector_deserializer< sparse_vector_u32 > sv_deserializer_type
static void SDemo1()
Demo 1 Simple one function call serialization.
bm::sparse_vector< unsigned, bm::bvector<> > sparse_vector_u32