1#ifndef BMSPARSEVEC_SERIAL__H__INCLUDED__
2#define BMSPARSEVEC_SERIAL__H__INCLUDED__
26#ifndef BM__H__INCLUDED__
29# error missing include (bm.h or bm64.h)
359 const unsigned char* buf,
360 bool clear_sv =
true);
374 bool clear_sv =
true);
398 const unsigned char* buf,
412 const unsigned char* buf);
432 const unsigned char* buf,
441 const unsigned char* buf,
445 void load_remap(SV& sv,
const unsigned char* remap_buf_ptr);
467 typedef bm::heap_vector<unsigned, alloc_type, true> rlen_vector_type;
540 const unsigned char* buf,
587 const unsigned char* buf,
631 buffer_coll.calc_stat(&st);
633 buf.resize(st.max_serialize_mem);
636 unsigned char* buf_ptr = buf.data();
642 enc.
put_8((
unsigned char)bo);
644 unsigned char* mbuf1 = enc.
get_pos();
655 size_t addr_bv_size = bvs.
serialize(bv, buf_ptr, buf.size());
656 buf_ptr += addr_bv_size;
662 size_t coll_size = buffer_coll.size();
668 for (
unsigned i = 0; i < buffer_coll.size(); ++i)
671 size_t sz = cbuf.size();
677 for (
unsigned i = 0; i < buffer_coll.size(); ++i)
680 size_t sz = cbuf.size();
681 enc.
memcpy(cbuf.buf(), sz);
684 buf.resize(enc.
size());
691 const unsigned char* buf,
698 unsigned char h1 = dec.
get_8();
699 unsigned char h2 = dec.
get_8();
702 if (h1 !=
'B' && h2 !=
'C')
714 const unsigned char* bv_buf_ptr = dec.
get_pos();
724 dec.
seek((
int)addr_bv_size);
730 if (coll_size != addr_cnt)
735 typedef size_t vect_size_type;
736 bm::heap_vector<bm::id64_t, allocator_type, true> buf_size_vec;
738 buf_size_vec.resize(vect_size_type(coll_size));
740 for (
unsigned i = 0; i < coll_size; ++i)
743 buf_size_vec[i] = sz;
749 buf_vect.resize(vect_size_type(coll_size));
750 for (
unsigned i = 0; i < coll_size; ++i)
755 dec.
memcpy(b.data(),
size_t(sz));
784 bv_ref_ptr_ = bv_ref_ptr;
785 is_xor_ref_ = bool(bv_ref_ptr);
795 is_xor_ref_ = is_enabled;
806 bvs_.compute_sim_model(sim_model, ref_vect, params);
815 sim_model_ptr_ = sim_model;
824 bv_ref_.build(sv.get_bmatrix());
833 const typename SV::remap_matrix_type* rm = sv.get_remap_matrix();
838 size_t rows = rmatr.rows();
839 size_t cols = rmatr.cols();
845 remap_rlen_vect_.resize(0);
846 for (
size_t r = 0; r < rows; ++r)
848 const unsigned char*
BMRESTRICT remap_row = rmatr.row(r);
852 remap_rlen_vect_.push_back(
unsigned(cnt));
855 rows = remap_rlen_vect_.size();
858 for (
size_t r = 0; r < rows; ++r)
860 unsigned rl = remap_rlen_vect_[r];
861 csr_size_max += rl * 2;
864 size_t remap_size = sv.remap_size();
866 if (remap_size < csr_size_max)
868 const unsigned char* matrix_buf = sv.get_remap_buffer();
874 enc.
memcpy(matrix_buf,
size_t(remap_size));
879 enc.
put_32(
unsigned(rows));
884 for (
size_t r = 0; r < rows; ++r)
886 unsigned rl = remap_rlen_vect_[r];
891 for (
size_t r = 0; r < rows; ++r)
893 const unsigned char*
BMRESTRICT row = rmatr.row(r);
894 for (
size_t j = 0; j < cols; ++j)
896 unsigned char v = row[j];
899 enc.
put_8((
unsigned char)j);
916 digest_bv.clear(
false);
917 unsigned planes = (unsigned)sv.get_bmatrix().rows();
918 for (
unsigned i = 0; i < planes; ++i)
920 typename SV::bvector_type_const_ptr bv = sv.get_slice(i);
922 digest_bv.set_bit_no_check(i);
932 bvs_.allow_stat_reset(
false);
933 bvs_.reset_compression_stats();
937 unsigned char* buf = sv_layout.
reserve(4);
938 buf[0]=
'B'; buf[1] =
'Z';
943 build_plane_digest(plane_digest_bv_, sv);
944 bvs_.set_ref_vectors(0);
945 bvs_.serialize(plane_digest_bv_, plane_digest_buf_);
947 unsigned planes = (unsigned)sv.get_bmatrix().rows();
953 typename SV::statistics sv_stat;
954 sv.calc_stat(&sv_stat);
955 sv_stat.max_serialize_mem += plane_digest_buf_.size() + (8 * planes);
956 unsigned char* buf = sv_layout.
reserve(sv_stat.max_serialize_mem);
963 unsigned h_size = 1 + 1 +
984 bvs_.set_ref_vectors(bv_ref_ptr_);
985 bvs_.set_sim_model(sim_model_ptr_);
990 build_xor_ref_vector(sv);
991 bvs_.set_ref_vectors(&bv_ref_);
992 if (bvs_.compute_sim_model(sim_model_, bv_ref_, xs_params))
993 bvs_.set_sim_model(&sim_model_);
1001 ::memset(buf, 0, h_size);
1002 unsigned char* buf_ptr = buf + h_size;
1004 for (
unsigned i = 0; i < planes; ++i)
1006 typename SV::bvector_type_const_ptr bv = sv.get_slice(i);
1016 idx = (unsigned)bv_ref_ptr_->find_bv(bv);
1018 idx = (unsigned)bv_ref_.find_bv(bv);
1020 bvs_.set_curr_ref_idx(idx);
1022 size_t buf_size = (size_t)
1023 bvs_.serialize(*bv, buf_ptr, sv_stat.max_serialize_mem);
1025 sv_layout.
set_plane(i, buf_ptr, buf_size);
1026 buf_ptr += buf_size;
1027 if (sv_stat.max_serialize_mem > buf_size)
1029 sv_stat.max_serialize_mem -= buf_size;
1035 bvs_.set_ref_vectors(0);
1042 bm::encoder enc_m(buf_ptr, sv_stat.max_serialize_mem);
1044 encode_remap_matrix(enc_m, sv);
1047 buf_ptr += enc_m.
size();
1053 size_t digest_offset = size_t(buf_ptr - buf);
1054 ::memcpy(buf_ptr, plane_digest_buf_.buf(), plane_digest_buf_.size());
1055 buf_ptr += plane_digest_buf_.size();
1057 bool use_64bit =
false;
1058 plane_off_vect_.resize(0);
1059 for (
unsigned i = 0; i < planes; ++i)
1061 const unsigned char* p = sv_layout.
get_plane(i);
1064 size_t offset = size_t(p - buf);
1070 plane_off_vect_.push_back(
unsigned(offset));
1073 bm::encoder enc_o(buf_ptr, sv_stat.max_serialize_mem);
1074 if (use_64bit || (plane_off_vect_.size() < 4))
1079 for (
unsigned i = 0; i < planes; ++i)
1081 const unsigned char* p = sv_layout.
get_plane(i);
1084 size_t offset = size_t(p - buf);
1091 BM_ASSERT(plane_off_vect_.size() == plane_digest_bv_.count());
1092 unsigned min_v = plane_off_vect_[0];
1093 unsigned max_v = plane_off_vect_[plane_off_vect_.size()-1];
1101 unsigned(plane_off_vect_.size()-2),
1104 buf_ptr += enc_o.
size();
1109 sv_layout.
resize(
size_t(buf_ptr - buf));
1117 if (sv.is_compressed())
1122 enc.
put_8((
unsigned char)bo);
1124 unsigned char matr_s_ser = 1;
1130 enc.
put_8(matr_s_ser);
1132 bm::id64_t planes_code = planes | (1ull << 63);
1135 enc.
put_64(sv.size_internal());
1143template<
typename SV>
1145 : remap_buf_ptr_(0), bv_ref_ptr_(0), idx_range_set_(false)
1154template<
typename SV>
1158 bv_ref_ptr_ = bv_ref_ptr;
1160 clear_xor_compression();
1166template<
typename SV>
1170 alloc_.free_bit_block(temp_block_);
1175template<
typename SV>
1178 op_deserial_.set_ref_vectors(0);
1179 deserial_.set_ref_vectors(0);
1185template<
typename SV>
1190 op_deserial_.set_ref_vectors(bv_ref_ptr_);
1191 deserial_.set_ref_vectors(bv_ref_ptr_);
1195 op_deserial_.set_ref_vectors(&bv_ref_);
1196 deserial_.set_ref_vectors(&bv_ref_);
1202template<
typename SV>
1204 const unsigned char* buf,
1207 idx_range_set_ =
false;
1208 deserialize_sv(sv, buf, 0, clear_sv);
1213template<
typename SV>
1215 const unsigned char* buf)
1219 unsigned char matr_s_ser = 0;
1220 unsigned planes = load_header(dec, sv, matr_s_ser);
1225 load_planes_off_table(buf, dec, planes);
1227 for (
unsigned i = 0; i < planes; ++i)
1240template<
typename SV>
1242 const unsigned char* buf,
1250 idx_range_set_ =
true; idx_range_from_ = from; idx_range_to_ = to;
1255 unsigned char matr_s_ser = 0;
1256 unsigned planes = load_header(dec, sv, matr_s_ser);
1261 sv.resize_internal(
size_type(sv_size_));
1264 load_planes_off_table(buf, dec, planes);
1266 setup_xor_compression();
1268 sv.get_bmatrix().allocate_rows(planes);
1271 planes = (unsigned)load_null_plane(sv,
int(planes), buf, 0);
1278 bool range_valid = sv.resolve_range(from, to, &sv_left, &sv_right);
1282 idx_range_set_ =
false;
1287 idx_range_set_ =
true; idx_range_from_ = sv_left; idx_range_to_ = sv_right;
1291 deserialize_planes(sv, planes, buf, 0);
1293 clear_xor_compression();
1300 load_remap(sv, remap_buf_ptr_);
1307 idx_range_set_ =
false;
1312template<
typename SV>
1314 const unsigned char* buf,
1324 unsigned char matr_s_ser = 0;
1325 unsigned planes = load_header(dec, sv, matr_s_ser);
1329 sv.resize_internal(
size_type(sv_size_));
1332 load_planes_off_table(buf, dec, planes);
1334 setup_xor_compression();
1336 sv.get_bmatrix().allocate_rows(planes);
1337 planes = (unsigned)load_null_plane(sv,
int(planes), buf, mask_bv);
1347 rsc_mask_bv_.clear(
true);
1349 rsc_compressor_.compress(rsc_mask_bv_, *bv_null, not_null_mask_bv_);
1350 mask_bv = &rsc_mask_bv_;
1356 rsc_mask_bv_.find_range(idx_range_from_, idx_range_to_);
1361 deserialize_planes(sv, planes, buf, mask_bv);
1365#pragma warning( push )
1366#pragma warning( disable : 4127)
1368 if (sv.max_vector_size == 1)
1371 const bvector_type* bv_null = sv.get_slice(sv.sv_value_slices);
1373 sv.mark_null_idx(sv.sv_value_slices);
1376#pragma warning( pop )
1380 clear_xor_compression();
1387 load_remap(sv, remap_buf_ptr_);
1396template<
typename SV>
1398 bm::decoder& dec, SV& sv,
unsigned char& matr_s_ser)
1402 unsigned char h1 = dec.
get_8();
1403 unsigned char h2 = dec.
get_8();
1405 BM_ASSERT(h1 ==
'B' && (h2 ==
'M' || h2 ==
'C' || h2 ==
'Z'));
1407 bool sig2_ok = (h2 ==
'M' || h2 ==
'C' || h2 ==
'Z');
1408 if (h1 !=
'B' || !sig2_ok)
1409 raise_invalid_header();
1410 unsigned planes = 0;
1417 unsigned char bv_bo = dec.
get_8(); (void) bv_bo;
1418 planes = dec.
get_8();
1421 matr_s_ser = dec.
get_8();
1422 planes_code = dec.
get_64();
1423 planes = (unsigned) planes_code;
1427 if (matr_s_ser == 2)
1428 raise_invalid_64bit();
1431 if constexpr (SV::is_dynamic_splices::value ==
false)
1433 unsigned sv_planes = sv.stored_slices();
1434 if (!planes || planes > sv_planes)
1435 raise_invalid_bitdepth();
1441 if (planes_code & (1ull << 63))
1443 digest_offset_ = dec.
get_64();
1451template<
typename SV>
1455 const unsigned char* buf,
1458 if (mask_bv && !idx_range_set_)
1459 idx_range_set_ = mask_bv->find_range(idx_range_from_, idx_range_to_);
1464 for (
int i =
int(planes-1); i >= 0; --i)
1466 size_t offset = off_vect_[unsigned(i)];
1469 const unsigned char* bv_buf_ptr = buf + offset;
1475 bv_ref_.add(bv,
unsigned(i));
1484 deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1485 remap_buf_ptr_ = bv_buf_ptr + read_bytes;
1490 deserial_.set_range(idx_range_from_, idx_range_to_);
1492 deserial_.deserialize(*bv, bv_buf_ptr);
1502 deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1503 remap_buf_ptr_ = bv_buf_ptr + read_bytes;
1505 bv->keep_range(idx_range_from_, idx_range_to_);
1510 deserial_.set_range(idx_range_from_, idx_range_to_);
1511 deserial_.deserialize(*bv, bv_buf_ptr);
1512 bv->keep_range(idx_range_from_, idx_range_to_);
1517 deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1523 deserial_.unset_range();
1529template<
typename SV>
1532 const unsigned char* buf,
1536 if (!sv.is_nullable())
1539 size_t offset = off_vect_[unsigned(i)];
1545 const unsigned char* bv_buf_ptr = buf + offset;
1549 bv_ref_.add(bv,
unsigned(i));
1555 size_t read_bytes = deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1556 remap_buf_ptr_ = bv_buf_ptr + read_bytes;
1565 size_t read_bytes = deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1566 remap_buf_ptr_ = bv_buf_ptr + read_bytes;
1568 bv->keep_range(idx_range_from_, idx_range_to_);
1573 deserial_.set_range(idx_range_from_, idx_range_to_);
1574 deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1575 bv->keep_range(idx_range_from_, idx_range_to_);
1576 deserial_.unset_range();
1580 deserial_.deserialize(*bv, bv_buf_ptr, temp_block_);
1591template<
typename SV>
1593 const unsigned char* buf,
bm::decoder& dec,
unsigned planes)
1595 off_vect_.resize(planes);
1598 plane_digest_bv_.clear(
false);
1599 const unsigned char* buf_ptr = buf + digest_offset_;
1601 deserial_.deserialize(plane_digest_bv_, buf_ptr, temp_block_);
1602 buf_ptr += read_bytes;
1606 unsigned char dtype = dec_o.
get_8();
1610 for (
unsigned i = 0; i < planes; ++i)
1613 if (plane_digest_bv_.test(i))
1614 offset = (size_t) dec_o.
get_64();
1615 off_vect_[i] = offset;
1620 unsigned osize = (unsigned)plane_digest_bv_.count();
1622 off32_vect_.resize(osize);
1624 unsigned min_v = dec_o.
get_32();
1625 unsigned max_v = dec_o.
get_32();
1627 off32_vect_[0] = min_v;
1628 off32_vect_[osize-1] = max_v;
1634 for (
unsigned i = 0; i < planes; ++i)
1636 if (plane_digest_bv_.test(i))
1638 off_vect_[i] = off32_vect_[k];
1653 for (
unsigned i = 0; i < planes; ++i)
1655 size_t offset = (size_t) dec.
get_64();
1656 off_vect_[i] = offset;
1663template<
typename SV>
1665 const unsigned char* remap_buf_ptr)
1672 unsigned char rh = dec_m.
get_8();
1679 size_t remap_size = (size_t) dec_m.
get_64();
1680 unsigned char* remap_buf = sv.init_remap_buffer();
1682 size_t target_remap_size = sv.remap_size();
1683 if (!remap_size || !remap_buf || remap_size != target_remap_size)
1685 raise_invalid_format();
1687 dec_m.
memcpy(remap_buf, remap_size);
1694 typename SV::remap_matrix_type* rmatr = sv.get_remap_matrix();
1697 raise_missing_remap_matrix();
1699 size_t rows = (size_t) dec_m.
get_32();
1700 size_t cols = dec_m.
get_16();
1703 raise_invalid_format();
1705 rmatr->resize(rows, cols,
false);
1711 remap_rlen_vect_.resize(0);
1714 for (
size_t r = 0; r < rows; ++r)
1716 unsigned rl = bi.
gamma();
1717 remap_rlen_vect_.push_back(rl);
1721 for (
size_t r = 0; r < rows; ++r)
1723 unsigned char*
BMRESTRICT row = rmatr->row(r);
1724 size_t cnt = remap_rlen_vect_[r];
1725 if (!cnt || cnt > 256)
1727 raise_invalid_format();
1729 for (
size_t j = 0; j < cnt; ++j)
1731 unsigned idx = dec_m.
get_8();
1732 unsigned char v = dec_m.
get_8();
1741 raise_invalid_format();
1746 unsigned char end_tok = dec_m.
get_8();
1749 raise_invalid_format();
1756template<
typename SV>
1760 throw std::logic_error(
"BitMagic: Invalid serialization signature header");
1762 BM_THROW(BM_ERR_SERIALFORMAT);
1768template<
typename SV>
1772 throw std::logic_error(
"BitMagic: Invalid serialization target (64-bit BLOB)");
1774 BM_THROW(BM_ERR_SERIALFORMAT);
1780template<
typename SV>
1784 throw std::logic_error(
"BitMagic: Invalid serialization target (bit depth)");
1786 BM_THROW(BM_ERR_SERIALFORMAT);
1792template<
typename SV>
1796 throw std::logic_error(
"BitMagic: Invalid serialization fromat (BLOB corruption?)");
1798 BM_THROW(BM_ERR_SERIALFORMAT);
1804template<
typename SV>
1808 throw std::logic_error(
"BitMagic: Invalid serialization format (remap matrix)");
1810 BM_THROW(BM_ERR_SERIALFORMAT);
Serialization / compression of bvector<>. Set theoretical operations on compressed BLOBs.
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
Byte based reader for un-aligned bit streaming.
unsigned gamma() BMNOEXCEPT
decode unsigned value using Elias Gamma coding
void bic_decode_u32_cm(bm::word_t *arr, unsigned sz, bm::word_t lo, bm::word_t hi) BMNOEXCEPT
Binary Interpolative array decode (32-bit)
Byte based writer for un-aligned bit streaming.
void bic_encode_u32_cm(const bm::word_t *arr, unsigned sz, bm::word_t lo, bm::word_t hi) BMNOEXCEPT
Binary Interpolative encoding (array of 32-bit ints) cm - "center-minimal".
void gamma(unsigned value) BMNOEXCEPT
Elias Gamma encode the specified value.
List of reference bit-vectors with their true index associations.
Bitvector Bit-vector container with runtime compression of bits.
@ opt_compress
compress blocks when possible (GAP/prefix sum)
allocator_type::allocator_pool_type allocator_pool_type
bvector_size_type size_type
Deseriaizer for compressed collections.
bvector_type::allocator_type allocator_type
CBC::buffer_type buffer_type
CBC::bvector_type bvector_type
CBC::statistics statistics_type
CBC::container_type container_type
CBC compressed_collection_type
int deserialize(CBC &buffer_coll, const unsigned char *buf, bm::word_t *temp_block=0)
CBC::address_resolver_type address_resolver_type
Seriaizer for compressed collections.
void serialize(const CBC &buffer_coll, buffer_type &buf, bm::word_t *temp_block=0)
CBC compressed_collection_type
CBC::bvector_type bvector_type
CBC::statistics statistics_type
CBC::address_resolver_type address_resolver_type
CBC::buffer_type buffer_type
const unsigned char * get_pos() const BMNOEXCEPT
Return current buffer pointer.
void seek(int delta) BMNOEXCEPT
change current position
unsigned char get_8() BMNOEXCEPT
Reads character from the decoding buffer.
void memcpy(unsigned char *dst, size_t count) BMNOEXCEPT
read bytes from the decode buffer
Class for decoding data from memory buffer.
bm::word_t get_32() BMNOEXCEPT
Reads 32-bit word from the decoding buffer.
bm::id64_t get_64() BMNOEXCEPT
Reads 64-bit word from the decoding buffer.
bm::short_t get_16() BMNOEXCEPT
Reads 16-bit word from the decoding buffer.
Deserializer for bit-vector.
size_t size() const BMNOEXCEPT
Returns size of the current encoding stream.
unsigned char * get_pos() const BMNOEXCEPT
Get current memory stream position.
void put_64(bm::id64_t w) BMNOEXCEPT
Puts 64 bits word into encoding buffer.
void put_8(unsigned char c) BMNOEXCEPT
Puts one character into the encoding buffer.
void set_pos(unsigned char *buf_pos) BMNOEXCEPT
Set current memory stream position.
void memcpy(const unsigned char *src, size_t count) BMNOEXCEPT
copy bytes into target buffer or just rewind if src is NULL
void put_32(bm::word_t w) BMNOEXCEPT
Puts 32 bits word into encoding buffer.
void put_16(bm::short_t s) BMNOEXCEPT
Puts short word (16 bits) into the encoding buffer.
Deserializer, performs logical operations between bit-vector and serialized bit-vector.
Algorithms for rank compression of bit-vector.
Bit-vector serialization class.
void gap_length_serialization(bool value) BMNOEXCEPT
Set GAP length serialization (serializes GAP levels of the original vector)
byte_buffer< allocator_type > buffer
void set_bookmarks(bool enable, unsigned bm_interval=256) BMNOEXCEPT
Add skip-markers to serialization BLOB for faster range decode at the expense of some BLOB size incre...
size_type serialize(const BV &bv, unsigned char *buf, size_t buf_size)
Bitvector serialization into memory block.
sparse vector de-serializer
sparse_vector_deserializer()
void deserialize_planes(SV &sv, unsigned planes, const unsigned char *buf, const bvector_type *mask_bv=0)
deserialize bit-vector planes
void setup_xor_compression()
setup deserializers
allocator_pool_type pool_
bm::operation_deserializer< bvector_type > op_deserial_
void deserialize(SV &sv, const unsigned char *buf, bool clear_sv=true)
bm::serializer< bvector_type >::bv_ref_vector_type bv_ref_vector_type
void deserialize(SV &sv, const unsigned char *buf, const bvector_type &mask_bv)
bm::rank_compressor< bvector_type > rsc_compressor_
void deserialize_structure(SV &sv, const unsigned char *buf)
bm::id64_t digest_offset_
void deserialize_sv(SV &sv, const unsigned char *buf, const bvector_type *mask_bv, bool clear_sv)
static void raise_invalid_bitdepth()
throw error on incorrect deserialization
static void raise_invalid_header()
throw error on incorrect deserialization
SV::bvector_type bvector_type
size_type idx_range_from_
bvector_type not_null_mask_bv_
bvector_type::allocator_type::allocator_pool_type allocator_pool_type
bvector_type::allocator_type alloc_type
static void raise_invalid_format()
throw error on incorrect deserialization
unsigned load_header(bm::decoder &dec, SV &sv, unsigned char &matr_s_ser)
Deserialize header/version and other common info.
void deserialize(SV &sv, const unsigned char *buf, size_type from, size_type to)
bm::heap_vector< size_t, alloc_type, true > off_vect_
~sparse_vector_deserializer()
bm::heap_vector< unsigned, alloc_type, true > off32_vect_
bvector_type * bvector_type_ptr
static void raise_invalid_64bit()
throw error on incorrect deserialization
bvector_type plane_digest_bv_
static void raise_missing_remap_matrix()
throw error on incorrect deserialization
const bvector_type * bvector_type_const_ptr
void set_xor_ref(bv_ref_vector_type *bv_ref_ptr)
Set external XOR reference vectors (data frame referenece vectors)
bv_ref_vector_type * bv_ref_ptr_
external ref
rlen_vector_type remap_rlen_vect_
bvector_type rsc_mask_bv_
bm::deserializer< bvector_type, bm::decoder > deserial_
const unsigned char * remap_buf_ptr_
bv_ref_vector_type bv_ref_
reference vector
int load_null_plane(SV &sv, int planes, const unsigned char *buf, const bvector_type *mask_bv)
load NULL bit-plane (returns new planes count)
void deserialize_range(SV &sv, const unsigned char *buf, size_type from, size_type to, bool clear_sv=true)
void load_planes_off_table(const unsigned char *buf, bm::decoder &dec, unsigned planes)
load offset table
void clear_xor_compression()
unset XOR compression vectors
void load_remap(SV &sv, const unsigned char *remap_buf_ptr)
load string remap dict
SV::value_type value_type
sparse_vector_serializer()
bvector_type plane_digest_bv_
bv.digest of bit-planes
u32_vector_type remap_rlen_vect_
void encode_remap_matrix(bm::encoder &enc, const SV &sv)
serialize the remap matrix used for SV encoding
serializer_type::buffer buffer_type
bm::serializer< bvector_type >::bv_ref_vector_type bv_ref_vector_type
static void build_plane_digest(bvector_type &digest_bv, const SV &sv)
void set_bookmarks(bool enable, unsigned bm_interval=256) BMNOEXCEPT
Add skip-markers for faster range deserialization.
const bv_ref_vector_type * bv_ref_ptr_
void set_xor_ref(bool is_enabled) BMNOEXCEPT
Turn ON and OFF XOR compression of sparse vectors Enables XOR reference compression for the sparse ve...
bvector_type * bvector_type_ptr
void build_xor_ref_vector(const SV &sv)
SV::value_type value_type
const bvector_type * bvector_type_const_ptr
bm::serializer< bvector_type > & get_bv_serializer() BMNOEXCEPT
Get access to the underlying bit-vector serializer This access can be used to fine tune compression s...
void compute_sim_model(xor_sim_model_type &sim_model, const bv_ref_vector_type &ref_vect, const bm::xor_sim_params ¶ms)
Calculate XOR similarity model for ref_vector refernece vector must be associated before.
alloc_type::allocator_pool_type allocator_pool_type
buffer_type plane_digest_buf_
serialization buf
void set_sim_model(const xor_sim_model_type *sim_model) BMNOEXCEPT
Attach serizalizer to a pre-computed similarity model.
u32_vector_type plane_off_vect_
bm::serializer< bvector_type > serializer_type
SV::remap_matrix_type remap_matrix_type
void serialize(const SV &sv, sparse_vector_serial_layout< SV > &sv_layout)
Serialize sparse vector into a memory buffer(s) structure.
xor_sim_model_type sim_model_
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.
const xor_sim_model_type * sim_model_ptr_
bm::heap_vector< unsigned, alloc_type, true > u32_vector_type
SV::bvector_type bvector_type
bm::serializer< bvector_type > bvs_
bvector_type::allocator_type alloc_type
bv_ref_vector_type bv_ref_
bm::serializer< bvector_type >::xor_sim_model_type xor_sim_model_type
bm::alloc_pool_guard< allocator_pool_type, bvector< Alloc > > mem_pool_guard
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.
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.
SZ count_nz(const VT *arr, SZ arr_size) BMNOEXCEPT
Find count of non-zero elements in the array.
ByteOrder
Byte orders recognized by the library.
unsigned long long int id64_t
unsigned short gap_word_t
ad-hoc conditional expressions
static ByteOrder byte_order()
layout class for serialization buffer structure
SV::bvector_type bvector_type
sizet_vector_type plane_size_
serialized plane size
serializer< bvector_type >::buffer buffer_type
void resize(size_t ssize)
Set new serialized size.
size_t capacity() const BMNOEXCEPT
return serialization buffer capacity
const unsigned char * get_plane(unsigned i) const BMNOEXCEPT
Get plane pointer.
unsigned char * reserve(size_t capacity)
resize capacity
size_t size() const BMNOEXCEPT
return current serialized size
void resize_slices(unsigned new_slices_size)
Resize for the target number of plains / bit-slices.
bm::heap_vector< unsigned char *, allocator_type, true > ptr_vector_type
const unsigned char * data() const BMNOEXCEPT
Return serialization buffer pointer.
sparse_vector_serial_layout() BMNOEXCEPT
ptr_vector_type plane_ptrs_
pointers on serialized bit-planes
buffer_type buf_
serialization buffer
void set_plane(unsigned i, unsigned char *ptr, size_t buf_size) BMNOEXCEPT
Set plane output pointer and size.
bvector_type::allocator_type allocator_type
bm::heap_vector< size_t, allocator_type, true > sizet_vector_type
void freemem() BMNOEXCEPT
free memory
SV::value_type value_type
~sparse_vector_serial_layout()
const unsigned char * buf() const BMNOEXCEPT
Return serialization buffer pointer.
Parameters for XOR similarity search.