1#ifndef BMSERIAL__H__INCLUDED__
2#define BMSERIAL__H__INCLUDED__
33#ifndef BM__H__INCLUDED__
36# error missing include (bm.h or bm64.h)
41#pragma warning( push )
42#pragma warning( disable : 4311 4312 4127)
85 typedef byte_buffer<allocator_type>
buffer;
134 {
return compression_level_; }
159 unsigned char* buf,
size_t buf_size);
197 {
return compression_stat_; }
203 { allow_stat_reset_ = allow; }
439 typedef bm::heap_vector<bm::gap_word_t, allocator_type, true> block_arridx_type;
440 typedef bm::heap_vector<unsigned, allocator_type, true> sblock_arridx_type;
441 typedef typename allocator_type::allocator_pool_type allocator_pool_type;
445 unsigned bit_model_d0_size_;
446 unsigned bit_model_0run_size_;
447 block_arridx_type bit_idx_arr_;
448 sblock_arridx_type sb_bit_idx_arr_;
455 bool allow_stat_reset_ =
true;
457 bool byte_order_serial_;
463 unsigned compression_level_;
464 bool own_temp_block_;
468 allocator_pool_type pool_;
471 unsigned char* enc_header_pos_;
472 unsigned char header_flag_;
484 unsigned sparse_cutoff_;
492template<
typename DEC,
typename BLOCK_IDX>
567template<
class BV,
class DEC>
592 const unsigned char* buf,
710template<class BV, class SerialIterator>
726 serial_iterator_type& sit,
729 bool exit_on_one =
false);
738 serial_iterator_type& sit,
751 serial_iterator_type& sit,
755 {
return "BM::de-serialization format error"; }
769template<
class DEC,
typename BLOCK_IDX>
785 bool is_eof()
const {
return end_of_stream_; }
794 unsigned get_bit_block(
bm::
word_t* dst_block,
803 unsigned dec_size()
const {
return decoder_.size(); }
870 return get_bit_block_COUNT(dst_block, tmp_block);
880 unsigned get_block_type() const
BMNOEXCEPT {
return block_type_; }
894 block_idx_ = new_nb; state_ = e_blocks;
952 const unsigned char* buf,
954 bool exit_on_one =
false);
964 const unsigned char* buf,
986 const unsigned char* buf,
989 bool exit_on_one =
false)
1000 const unsigned char* buf,
1017 const unsigned char* buf,
1026 const unsigned char* buf,
1057 deserializer_le de_le_;
1058 deserializer_be de_be_;
1173 compression_stat_(0),
1175 byte_order_serial_(true),
1176 sb_bookmarks_(false),
1179 enc_header_pos_(0), header_flag_(0),
1187 if (temp_block == 0)
1189 temp_block_ = alloc_.alloc_bit_block();
1190 own_temp_block_ =
true;
1194 temp_block_ = temp_block;
1195 own_temp_block_ =
false;
1197 compression_stat_ = (
size_type*) alloc_.alloc_bit_block();
1198 optimize_ = free_ =
false;
1199 xor_tmp1_ = xor_tmp2_ = 0;
1205 compression_stat_(0),
1207 byte_order_serial_(true),
1208 sb_bookmarks_(false),
1211 enc_header_pos_(0), header_flag_(0),
1219 if (temp_block == 0)
1221 temp_block_ = alloc_.alloc_bit_block();
1222 own_temp_block_ =
true;
1226 temp_block_ = temp_block;
1227 own_temp_block_ =
false;
1229 compression_stat_ = (
size_type*) alloc_.alloc_bit_block();
1230 optimize_ = free_ =
false;
1231 xor_tmp1_ = xor_tmp2_ = 0;
1237 if (own_temp_block_)
1238 alloc_.free_bit_block(temp_block_);
1239 if (compression_stat_)
1240 alloc_.free_bit_block((
bm::word_t*)compression_stat_);
1242 alloc_.free_bit_block(xor_tmp_block_, 3);
1249 for (
unsigned i = 0; i < 256; ++i)
1250 compression_stat_[i] = 0;
1257 compression_level_ = clevel;
1258 if (compression_level_ == 5)
1260 else if (compression_level_ == 6)
1269 sparse_cutoff_ = cutoff;
1277 gap_serial_ = value;
1283 byte_order_serial_ = value;
1289 sb_bookmarks_ = enable;
1292 if (bm_interval > 512)
1295 if (bm_interval < 4)
1298 sb_range_ = bm_interval;
1304 ref_vect_ = ref_vect;
1306 xor_scan_.set_ref_vector(ref_vect);
1307 if (!xor_tmp_block_ && ref_vect)
1309 xor_tmp_block_ = alloc_.alloc_bit_block(3);
1320 return xor_scan_.compute_sim_model(sim_model, ref_vect, params);
1326 sim_model_ = sim_model;
1346 if (!byte_order_serial_)
1362 enc_header_pos_ = enc.get_pos();
1363 enc.put_8(header_flag_);
1365 if (byte_order_serial_)
1368 enc.put_8((
unsigned char)bo);
1380 enc.put_64(bv.size());
1382 enc.put_32(bv.size());
1405 if (tail_delta < 256)
1411 enc.put_8((
unsigned char)min_v);
1415 if (tail_delta < 256)
1416 enc.put_8((
unsigned char)tail_delta);
1418 enc.put_16(tail_delta);
1427 unsigned gamma_size = (unsigned)(enc_pos1 - enc_pos0);
1430 enc.set_pos(enc_pos0);
1441 enc.put_16(gap_block, len-1);
1452 if (len > 3 && (compression_level_ > 3))
1460 enc.put_16(gap_block[0]);
1467 unsigned gamma_size = (unsigned)(enc_pos1 - enc_pos0);
1470 enc.set_pos(enc_pos0);
1481 enc.put_16(gap_block, len-1);
1494 if (compression_level_ > 3 && arr_len > 1)
1500 bout.
gamma(arr_len);
1502 bout.
gamma(prev + 1);
1504 for (
unsigned i = 1; i < arr_len; ++i)
1507 bout.
gamma(curr - prev);
1512 unsigned gamma_size = (unsigned)(enc_pos1 - enc_pos0);
1514 if (gamma_size >= plain_size)
1516 enc.set_pos(enc_pos0);
1520 compression_stat_[scode]++;
1526 enc.put_prefixed_array_16(scode, gap_array, arr_len,
true);
1527 compression_stat_[scode]++;
1555 bout.
gamma(arr_len-4);
1560 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
1562 if (enc_size >= raw_size)
1564 enc.set_pos(enc_pos0);
1568 compression_stat_[scode]++;
1574 enc.put_prefixed_array_16(scode, gap_block, arr_len,
true);
1575 compression_stat_[scode]++;
1595 if (min_v >= 256 && tail >= 256)
1597 interpolated_gap_array_v0(gap_block, arr_len, enc, inverted);
1615 arr_len |= (1 << 1);
1619 enc.put_8((
unsigned char)min_v);
1624 enc.put_8((
unsigned char)tail);
1634 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
1636 if (enc_size >= raw_size)
1638 enc.set_pos(enc_pos0);
1642 compression_stat_[scode]++;
1648 enc.put_prefixed_array_16(scode, gap_block, arr_len,
true);
1649 compression_stat_[scode]++;
1658 scores_[mod_size_] = score; models_[mod_size_] = mod;
1666 const float bie_bits_per_int = compression_level_ < 6 ? 3.75f : 2.5f;
1667 const unsigned bie_limit = unsigned(
float(
bm::gap_max_bits) / bie_bits_per_int);
1669 unsigned bc, ibc, gc;
1681 bit_model_d0_size_ = unsigned(8 + (32 * d0_bc *
sizeof(
bm::word_t)));
1694 unsigned arr_size_inv =
1701 float gcf=float(gc);
1705 32 +
unsigned((gcf-1) * bie_bits_per_int));
1708 float bcf=float(bc), ibcf=float(ibc);
1714 if (ibc < bie_limit)
1716 16 * 3 +
unsigned(ibcf * bie_bits_per_int));
1719 gc -= gc > 2 ? 2 : 0;
1724 16 * 4 +
unsigned(gcf * bie_bits_per_int));
1730 16 * 4 +
unsigned(gcf * bie_bits_per_int));
1737 for (
unsigned i = 0; i < mod_size_; ++i)
1739 if (scores_[i] < min_score)
1741 min_score = scores_[i];
1748 std::cout <<
" 0runs=" << (bit_model_0run_size_ * 8) << std::endl;
1749 std::cout <<
" GAP BIC=" << (16 * 4 + unsigned(gcf * bie_bits_per_int)) << std::endl;
1750 std::cout <<
" ARR BIC=" << (16 * 3 + unsigned(bcf * bie_bits_per_int)) << std::endl;
1751 std::cout <<
"BC,GC=[" << bc <<
", " << gc <<
"]" << std::endl;
1752 std::cout <<
"bie_limit=" << bie_limit << std::endl;
1757 case set_block_bit: std::cout <<
"BIT=" <<
"[" << bc <<
", " << gc <<
"]";
break;
1769 case set_block_bit_0runs: std::cout <<
"0runs=[" << bc <<
", " << gc <<
" lmt=" << bie_limit <<
"]";
break;
1772 default: std::cout <<
"UNK=" << int(model);
break;
1785 const float bie_bits_per_int = compression_level_ < 6 ? 3.75f : 2.5f;
1787 unsigned wave_matches[
e_bit_end] = {0, };
1790 unsigned s_gc, s_bc;
1796 s_gc = x_descr.
sb_gc[i];
1797 s_bc = x_descr.
sb_bc[i];
1801 wave_matches[best_rep]++;
1803 unsigned sum_cases = 0;
1804 bool sub_diff =
false;
1805 unsigned v_count = 0;
1806 for (
unsigned i = 0; i <
e_bit_end; ++i)
1808 sum_cases += wave_matches[i];
1809 if (wave_matches[i] != 0 && wave_matches[i] < 64)
1811 sub_diff =
true; v_count++;
1816 std::cout <<
"-" << v_count;
1821 if (wave_matches[i])
1825 case e_bit_GAP: std::cout <<
" G" << wave_matches[i];
break;
1826 case e_bit_INT: std::cout <<
" I" << wave_matches[i];
break;
1827 case e_bit_IINT: std::cout <<
"iI" << wave_matches[i];
break;
1828 case e_bit_1: std::cout <<
" 1s" << wave_matches[i];
break;
1829 case e_bit_0: std::cout <<
" 0s" << wave_matches[i];
break;
1830 case e_bit_bit: std::cout <<
" B" << wave_matches[i];
break;
1846 if (compression_level_ >= 5)
1847 return find_bit_best_encoding_l5(block);
1849 unsigned bc, bit_gaps;
1856 if (compression_level_ <= 1)
1861 if (compression_level_ <= 5)
1864 if (compression_level_ >= 2)
1873 bit_model_d0_size_ = unsigned(8 + (32 * d0_bc *
sizeof(
bm::word_t)));
1877 if (compression_level_ >= 4)
1900 if (compression_level_ >= 3)
1904 unsigned arr_size_inv =
1910 if (compression_level_ >= 4)
1912 const unsigned gamma_bits_per_int = 6;
1915 if (compression_level_ == 4)
1919 16 + (bit_gaps-1) * gamma_bits_per_int);
1922 16 + bc * gamma_bits_per_int);
1923 if (inverted_bc > 3 && inverted_bc < bit_gaps && inverted_bc <
bm::gap_equiv_len)
1925 16 + inverted_bc * gamma_bits_per_int);
1935 for (
unsigned i = 0; i < mod_size_; ++i)
1937 if (scores_[i] < min_score)
1939 min_score = scores_[i];
1953 if (compression_level_ <= 2)
1969 if (compression_level_ < 4 || len < 6)
1972 if (compression_level_ == 4)
1979 if (compression_level_ < 4 || len < 6)
1982 if (compression_level_ == 4)
1989 if (compression_level_ == 4)
2004 bool invert =
false;
2006 unsigned char enc_choice = find_gap_best_encoding(gap_block);
2010 gamma_gap_block(gap_block, enc);
2019 enc.
put_16(gap_temp_block[0]);
2036 gamma_gap_array(gap_temp_block, arr_len, enc, invert);
2039 interpolated_encode_gap_block(gap_block, enc);
2051 interpolated_gap_array(gap_temp_block, arr_len, enc, invert);
2054 gamma_gap_block(gap_block, enc);
2065 enc.put_8((blk[0]==0) ? 0 : 1);
2101 enc.put_32(blk + i, j - i);
2119 if (bit_model_0run_size_ < bit_model_d0_size_)
2121 encode_bit_interval(block, enc, 0);
2138 enc.put_32(block[off+j+0]);
2139 enc.put_32(block[off+j+1]);
2140 enc.put_32(block[off+j+2]);
2141 enc.put_32(block[off+j+3]);
2154 encode_bit_interval(block, enc, 0);
2173 enc.put_8(vbr_flag);
2177 ridx = ref_vect_->get_row_idx(ridx);
2181 case 1: enc.put_8((
unsigned char)ridx);
break;
2182 case 2: enc.put_16((
unsigned short)ridx);
break;
2183 case 0: enc.put_32((
unsigned)ridx);
break;
2187 enc.put_8((
unsigned char) (chain_size-1));
2189 for (
unsigned ci = 1; ci < chain_size; ++ci)
2191 ridx = mchain.ref_idx[ci];
2192 d64 = mchain.xor_d64[ci];
2193 ridx = ref_vect_->get_row_idx(ridx);
2196 case 1: enc.put_8((
unsigned char)ridx);
break;
2197 case 2: enc.put_16((
unsigned short)ridx);
break;
2198 case 0: enc.put_32((
unsigned)ridx);
break;
2217 s_block = xor_tmp1_;
2220 const bm::word_t* ref_block = xor_scan_.get_ref_block(ridx, i, j);
2224 ref_block = xor_tmp2_;
2228 for (
unsigned k = 1; k < mchain.chain_size; ++k)
2230 ridx = mchain.ref_idx[k];
2231 ref_block = xor_scan_.get_ref_block(ridx, i, j);
2235 ref_block = xor_tmp2_;
2237 d64 = mchain.xor_d64[k];
2251 bv.calc_stat(&stat);
2256 optimize_ = free_ =
false;
2258 unsigned char* data_buf = buf.data();
2259 size_t buf_size = buf.size();
2277 mp_g_z.assign_if_not_set(pool_, bv);
2279 bv.optimize(temp_block_, BV::opt_compress, &st);
2282 optimize_ = free_ =
false;
2295 unsigned char scode =
2297 enc.put_prefixed_array_16(scode, bit_idx_arr_.data(), arr_len,
true);
2298 compression_stat_[scode]++;
2301 encode_bit_digest(block, enc, digest0_);
2310 gamma_gap_block(bit_idx_arr_.data(), enc);
2322 gamma_gap_array(bit_idx_arr_.data(), arr_len, enc, inverted);
2338 interpolated_gap_array(bit_idx_arr_.data(), arr_len, enc, inverted);
2341 encode_bit_digest(block, enc, digest0_);
2350 interpolated_encode_gap_block(bit_idx_arr_.data(), enc);
2375 enc.put_8((
unsigned char)head);
2382 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
2384 if (enc_size >= raw_size)
2386 enc.set_pos(enc_pos0);
2390 compression_stat_[scode]++;
2396 encode_bit_digest(block, enc, digest0_);
2417 unsigned sb_flag = 0;
2421 unsigned len = (unsigned)sb_bit_idx_arr_.size();
2423 BM_ASSERT(sb_bit_idx_arr_.size() < 65536);
2441 if (min_v < 0xFFFFFF)
2445 else if (min_v > 255)
2448 if (max_v_delta > 65535)
2449 if (max_v_delta < 0xFFFFFF)
2453 else if (max_v_delta > 255)
2459 enc.put_8((
unsigned char)sb_flag);
2464 enc.put_16((
unsigned short)sb);
2466 enc.put_8((
unsigned char)sb);
2469 enc.put_16((
unsigned short)len);
2471 enc.put_8((
unsigned char)len);
2474 if (min_v < 0xFFFFFF)
2478 else if (min_v > 255)
2479 enc.put_16((
unsigned short)min_v);
2481 enc.put_8((
unsigned char)min_v);
2483 if (max_v_delta > 65535)
2484 if (max_v < 0xFFFFFF)
2485 enc.put_24(max_v_delta);
2487 enc.put_32(max_v_delta);
2488 else if (max_v_delta > 255)
2489 enc.put_16((
unsigned short)max_v_delta);
2491 enc.put_8((
unsigned char)max_v_delta);
2495 (
unsigned)sb_bit_idx_arr_.size()-2,
2498 compression_stat_[scode]++;
2510 bit_idx_arr_.data(), block, inverted);
2514 unsigned char scode =
2526 if (!inverted && min_v <= 0xFF && max_delta <= 0xFF)
2529 enc.put_8((
unsigned char)min_v);
2530 enc.put_8((
unsigned char)max_delta);
2544 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
2546 if (enc_size >= raw_size)
2548 enc.set_pos(enc_pos0);
2552 if (digest0_ != ~0ull && enc_size > bit_model_d0_size_)
2554 enc.set_pos(enc_pos0);
2558 compression_stat_[scode]++;
2565 encode_bit_digest(block, enc, digest0_);
2570#define BM_SER_NEXT_GRP(enc, nb, B_1ZERO, B_8ZERO, B_16ZERO, B_32ZERO, B_64ZERO) \
2572 enc.put_8(B_1ZERO); \
2573 else if (nb < 256u) \
2575 enc.put_8(B_8ZERO); \
2576 enc.put_8((unsigned char)nb); \
2578 else if (nb < 65536u) \
2580 enc.put_8(B_16ZERO); \
2581 enc.put_16((unsigned short)nb); \
2583 else if (nb < bm::id_max32) \
2585 enc.put_8(B_32ZERO); \
2586 enc.put_32(unsigned(nb)); \
2590 enc.put_8(B_64ZERO); \
2603 if (bookm.ptr_ && nb_delta >= bookm.nb_range_)
2605 unsigned char* curr = enc.get_pos();
2606 size_t bytes_delta = size_t(curr - bookm.ptr_);
2607 if (bytes_delta > bookm.min_bytes_range_)
2609 enc.set_pos(bookm.ptr_);
2610 switch (bookm.bm_type_)
2613 bytes_delta -=
sizeof(unsigned);
2614 if (bytes_delta < 0xFFFFFFFF)
2615 enc.put_32(
unsigned(bytes_delta));
2619 bytes_delta -= (
sizeof(unsigned)-1);
2620 if (bytes_delta < 0xFFFFFF)
2621 enc.put_24(
unsigned(bytes_delta));
2624 bytes_delta -=
sizeof(
unsigned short);
2625 if (bytes_delta < 0xFFFF)
2626 enc.put_16((
unsigned short)bytes_delta);
2635 if (nb_delta < 0xFF)
2638 enc.put_8((
unsigned char) nb_delta);
2641 if (nb_delta < 0xFFFF)
2644 enc.put_16((
unsigned short) nb_delta);
2647 if (nb_delta < 0xFFFFFF)
2650 enc.put_24(
unsigned(nb_delta));
2656 enc.put_32(
unsigned(nb_delta));
2661 if (nb_delta < 0xFFFFFFFFFFFFUL)
2664 enc.put_48(nb_delta);
2669 enc.put_64(nb_delta);
2681 bookm.ptr_ = enc.get_pos() + 1;
2682 switch (bookm.bm_type_)
2707 unsigned char* buf,
size_t buf_size)
2711 if (allow_stat_reset_)
2712 reset_compression_stats();
2716 enc_header_pos_ = 0;
2717 encode_header(bv, enc);
2721 unsigned i_last = ~0u;
2729 if (i0 < bman.top_block_size())
2736 process_bookmark(i, sb_bookmark, enc);
2743 if ((compression_level_ >= 5) && (i0 != i_last))
2746 bool is_sparse_sub = bman.is_sparse_sblock(i0, sparse_cutoff_);
2750 bienc_arr_sblock(bv, i0, enc);
2761 const bm::word_t* blk = bman.get_block(i0, j0);
2782 enc.
put_8(header_flag_);
2787 if (nb > 1 && nb < 128)
2790 unsigned char c = (
unsigned char)((1u << 7) | nb);
2817 bm::word_t*** blk_root = bman.top_blocks_root();
2824 const bm::word_t* blk_next = bman.get_block(i0, j0);
2856 bool nb_indexed = sim_model_->bv_blocks.test(i);
2861 size_type rank = sim_model_->bv_blocks.count_range(0, i);
2865 sim_model_->matr.get(ref_idx_, rank);
2867 switch (mchain.
match)
2875 size_type plain_idx = ref_vect_->get_row_idx(ridx);
2877 enc.
put_32(
unsigned(plain_idx));
2887 xor_tmp_product(blk, mchain, i0, j0);
2893 size_type plain_idx = ref_vect_->get_row_idx(ridx);
2913 encode_xor_match_chain(enc, mchain);
2915 blk = xor_tmp_block_;
2937 unsigned char model = find_bit_best_encoding(blk);
2945 unsigned bit_idx = 0;
2958 encode_bit_array(blk, enc,
false);
2961 encode_bit_array(blk, enc,
true);
2964 gamma_gap_bit_block(blk, enc);
2967 encode_bit_interval(blk, enc, 0);
2970 gamma_arr_bit_block(blk, enc,
false);
2973 gamma_arr_bit_block(blk, enc,
true);
2976 bienc_arr_bit_block(blk, enc,
false);
2979 bienc_arr_bit_block(blk, enc,
true);
2982 interpolated_arr_bit_block(blk, enc,
false);
2985 interpolated_arr_bit_block(blk, enc,
true);
2988 interpolated_gap_bit_block(blk, enc);
2991 bienc_gap_bit_block(blk, enc);
2994 encode_bit_digest(blk, enc, digest0_);
3017 enc.
put_8(header_flag_);
3089 return (
size_t) bv_serial.
serialize(bv, buf, 0);
3141 const unsigned char* buf,
3148 unsigned char header_flag = dec.
get_8();
3155 if (bo_current == bo)
3204 const unsigned char* buf,
3205 typename BV::size_type from,
3206 typename BV::size_type to,
3212 unsigned char header_flag = dec.
get_8();
3219 if (bo_current == bo)
3250 bv.keep_range(from, to);
3254template<
typename DEC,
typename BLOCK_IDX>
3257 unsigned block_type,
3282 if (k == 0) --bit_idx;
3285 dst_arr[k] = bit_idx;
3298 dst_arr[len-1] = max_v;
3322 dst_arr[len-1] = max_v;
3330 throw std::logic_error(err_msg());
3332 BM_THROW(BM_ERR_SERIALFORMAT);
3338template<
typename DEC,
typename BLOCK_IDX>
3350 min_v = dec.get_16();
3351 max_v = dec.get_16();
3354 min_v = dec.get_8();
3355 max_delta = dec.get_8();
3363 arr_len = dec.get_16();
3377template<
typename DEC,
typename BLOCK_IDX>
3380 unsigned block_type,
3384 unsigned len(0), sb_flag(0);
3392 sb_flag = dec.get_8();
3395 *sb_idx = dec.get_32();
3397 *sb_idx = dec.get_16();
3399 *sb_idx = dec.get_8();
3409 min_v = dec.get_32();
3411 min_v = dec.get_24();
3413 min_v = dec.get_16();
3415 min_v = dec.get_8();
3420 max_v = dec.get_32();
3422 max_v = dec.get_24();
3424 max_v = dec.get_16();
3426 max_v = dec.get_8();
3430 dst_arr[len-1] = max_v;
3437 throw std::logic_error(err_msg());
3439 BM_THROW(BM_ERR_SERIALFORMAT);
3446template<
typename DEC,
typename BLOCK_IDX>
3457template<
typename DEC,
typename BLOCK_IDX>
3464 unsigned arr_len = dec.get_16();
3468 id_array_[0] = head;
3469 id_array_[1] = min_v;
3470 id_array_[arr_len] = 65535;
3480template<
typename DEC,
typename BLOCK_IDX>
3508 block[off+j+0] |= dec.get_32();
3509 block[off+j+1] |= dec.get_32();
3510 block[off+j+2] |= dec.get_32();
3511 block[off+j+3] |= dec.get_32();
3520template<
typename DEC,
typename BLOCK_IDX>
3528 unsigned char run_type = dec.get_8();
3531 unsigned run_length = dec.get_16();
3534 unsigned run_end = j + run_length;
3536 for (;j < run_end; ++j)
3538 unsigned w = dec.get_32();
3550template<
typename DEC,
typename BLOCK_IDX>
3553 unsigned block_type,
3564 *dst_block = gap_head;
3595 unsigned arr_len = read_id_list(
decoder, block_type, id_array_);
3605 unsigned len = (gap_head >> 3);
3608 *dst_block = gap_head;
3614 for (
unsigned i = 1; i < len; ++i)
3618 *(++gap_data_ptr) = gap_sum;
3625 unsigned len = (gap_head >> 3);
3626 *dst_block = gap_head;
3628 dst_block[1] = min_v;
3637 unsigned len = (gap_head >> 3);
3651 dst_block[0] = gap_head;
3652 dst_block[1] = min_v;
3655 dst_block[len-1] = max_v;
3662 throw std::logic_error(err_msg());
3664 BM_THROW(BM_ERR_SERIALFORMAT);
3677template<
typename DEC,
typename BLOCK_IDX>
3688 if (save_pos > skip_pos_)
3737 if (nb_sync <= expect_nb)
3751template<
class BV,
class DEC>
3772template<
class BV,
class DEC>
3775 alloc_.free_bit_block(temp_block_);
3777 alloc_.free_bit_block(xor_block_, 2);
3781template<
class BV,
class DEC>
3784 ref_vect_ = ref_vect;
3785 if (ref_vect_ && !xor_block_)
3786 xor_block_ = alloc_.alloc_bit_block(2);
3789template<
class BV,
class DEC>
3799 bool inv_flag =
false;
3802 bman.reserve_top_blocks(i0+1);
3803 bman.check_alloc_top_subblock(i0);
3812 (
sizeof(
gap_word_t) == 2 ? dec.get_16() : dec.get_32());
3819 *gap_temp_block = gap_head;
3820 dec.get_16(gap_temp_block+1, len - 1);
3825 blk = bman.get_allocator().alloc_bit_block();
3826 bman.set_block(nb, blk);
3833 bv.combine_operation_block_or(i0, j0, blk, temp_block_);
3844 bman.get_allocator().alloc_gap_block(
unsigned(level), bman.glen());
3846 *gap_blk_ptr = gap_head;
3852 dec.get_16(gap_blk + 1, len - 1);
3858 *gap_temp_block = gap_head;
3859 dec.get_16(gap_temp_block + 1, len - 1);
3876 unsigned arr_len = this->read_id_list(dec, btype, this->id_array_);
3877 gap_temp_block[0] = 0;
3888 bv.combine_operation_block_or(i0, j0, blk, temp_block_);
3894 gap_head = dec.get_16();
3901 this->read_gap_block(dec, btype, gap_temp_block, gap_head);
3906 gap_head = dec.get_16();
3907 this->read_gap_block(dec, btype, gap_temp_block, gap_head);
3912 throw std::logic_error(this->err_msg());
3914 BM_THROW(BM_ERR_SERIALFORMAT);
3922 blk = bman.get_allocator().alloc_bit_block();
3924 bman.set_block_ptr(i0, j0, blk);
3929 bv.combine_operation_block_or(i0, j0, blk, temp_block_);
3936 bv.combine_operation_block_or(i0, j0, blk, tmp_blk);
3940template<
class BV,
class DEC>
3949 blk = bman.get_allocator().alloc_bit_block();
3950 bman.set_block(nb, blk);
3955 blk = bman.deoptimize_block(nb);
3963 blk = bman.deoptimize_block(nb);
3967 for (
unsigned k = 0; k < len; ++k)
3977 this->read_bic_arr(dec, blk, btype);
3982 blk = bman.deoptimize_block(nb);
3990 this->read_bic_gap(dec, blk);
3993 this->read_digest0_block(dec, blk);
3998 throw std::logic_error(this->err_msg());
4000 BM_THROW(BM_ERR_SERIALFORMAT);
4005template<
class BV,
class DEC>
4011 unsigned* arr = this->sb_id_array_;
4012 unsigned len = this->read_bic_sb_arr(dec, btype, arr, &sb);
4014 typename BV::size_type from = sb * sb_max_bc;
4018 for (
typename BV::size_type i = 0; i < len; ++i)
4020 typename BV::size_type idx = from + arr[i];
4023 if (idx < idx_from_)
4025 bv.set_bit_no_check(idx);
4030 for (
typename BV::size_type i = 0; i < len; ++i)
4032 typename BV::size_type idx = from + arr[i];
4033 bv.set_bit_no_check(idx);
4039template<
class BV,
class DEC>
4048 blk = bman.get_allocator().alloc_bit_block();
4049 bman.set_block(nb, blk);
4055 bv.combine_operation_with_block(nb, temp_block_, 0,
BM_OR);
4059template<
class BV,
class DEC>
4065 unsigned head_idx = dec.get_16();
4066 unsigned tail_idx = dec.get_16();
4070 blk = bman.get_allocator().alloc_bit_block();
4071 bman.set_block(nb, blk);
4072 for (
unsigned k = 0; k < head_idx; ++k)
4074 dec.get_32(blk + head_idx, tail_idx - head_idx + 1);
4081 dec.get_32(temp_block_ + head_idx, tail_idx - head_idx + 1);
4082 bv.combine_operation_with_block(nb, temp_block_, 0,
BM_OR);
4086template<
class BV,
class DEC>
4096 blk = bman.deoptimize_block(nb);
4102 blk = bman.get_allocator().alloc_bit_block();
4104 bman.set_block(nb, blk);
4109 for (
unsigned k = 0; k < len; ++k)
4115 for (
unsigned k = 0; k < len; ++k)
4124template<
class BV,
class DEC>
4126 const unsigned char* buf,
4130 if (!bman.is_init())
4136 bv.set_new_blocks_strat(
BM_GAP);
4138 mp_guard_bv.assign_if_not_set(pool_, bv);
4145 unsigned char header_flag = dec.get_8();
4155 throw std::logic_error(this->err_msg());
4157 BM_THROW(BM_ERR_SERIALFORMAT);
4174 bv_size = dec.get_32();
4175 if (bv_size > bv.size())
4178 for (
unsigned cnt = dec.get_32(); cnt; --cnt)
4184 return dec.size()-1;
4204 throw std::logic_error(this->err_msg());
4206 BM_THROW(BM_ERR_SERIALFORMAT);
4211 bv_size = dec.get_32();
4212 if (bv_size > bv.size())
4219 xor_block_ = alloc_.alloc_bit_block();
4230 unsigned row_idx(0);
4234 unsigned char btype;
4248 btype = dec.get_8();
4249 if (btype & (1 << 7))
4251 nb = btype & ~(1 << 7);
4257 bm::word_t* blk = bman.get_block_ptr(i0, j0);
4291 throw std::logic_error(this->err_msg());
4293 BM_THROW(BM_ERR_SERIALFORMAT);
4302 bman.set_block_all_set(nb_i);
4305 full_blocks = dec.get_8();
4306 goto process_full_blocks;
4309 full_blocks = dec.get_16();
4310 goto process_full_blocks;
4313 full_blocks = dec.get_32();
4314 goto process_full_blocks;
4318 full_blocks = dec.get_64();
4319 goto process_full_blocks;
4324 throw std::logic_error(this->err_msg());
4326 BM_THROW(BM_ERR_SERIALFORMAT);
4329 process_full_blocks:
4334 bv.set_range(from, to-1);
4335 nb_i += full_blocks-1;
4339 decode_block_bit(dec, bv, nb_i, blk);
4345 bv.set_bit_no_check(bit_idx);
4351 this->read_0runs_block(dec, temp_block);
4352 bv.combine_operation_with_block(nb_i, temp_block, 0,
BM_OR);
4356 decode_block_bit_interval(dec, bv, nb_i, blk);
4371 deserialize_gap(btype, dec, bv, bman, nb_i, blk);
4374 decode_arrbit(dec, bv, nb_i, blk);
4381 decode_bit_block(btype, dec, bman, nb_i, blk);
4384 decode_bit_block(btype, dec, bman, nb_i, blk);
4389 decode_arr_sblock(btype, dec, bv);
4396 this->bookmark_idx_ = nb_i;
4397 this->skip_offset_ = dec.get_32();
4398 goto process_bookmark;
4400 this->bookmark_idx_ = nb_i;
4401 this->skip_offset_ = dec.get_24();
4402 goto process_bookmark;
4404 this->bookmark_idx_ = nb_i;
4405 this->skip_offset_ = dec.get_16();
4409 this->skip_pos_ = dec.get_pos() + this->skip_offset_;
4411 nb_from = this->try_skip(dec, nb_i, nb_from);
4418 nb_sync = dec.get_8();
4419 goto process_nb_sync;
4421 nb_sync = dec.get_16();
4422 goto process_nb_sync;
4424 nb_sync = dec.get_24();
4425 goto process_nb_sync;
4427 nb_sync = dec.get_32();
4428 goto process_nb_sync;
4431 goto process_nb_sync;
4435 BM_ASSERT(nb_i == this->bookmark_idx_ + nb_sync);
4436 if (nb_i != this->bookmark_idx_ + nb_sync)
4439 throw std::logic_error(this->err_msg());
4441 BM_THROW(BM_ERR_SERIALFORMAT);
4454 row_idx = dec.get_32();
4455 size_type idx = ref_vect_->find(row_idx);
4456 if (idx == ref_vect_->not_found())
4465 const bm::word_t* ref_blk = ref_bman.get_block_ptr(i0, j0);
4467 bv.combine_operation_with_block(nb_i, ref_blk,
4475 row_idx = dec.get_8();
4481 row_idx = dec.get_16();
4488 row_idx = dec.get_32();
4491 x_ref_d64_ = dec.get_64();
4496 x_ref_idx_ = ref_vect_->find(row_idx);
4498 if (x_ref_idx_ == ref_vect_->not_found())
4506 or_block_ = bman.deoptimize_block(nb_i);
4507 bman.set_block_ptr(nb_i, 0);
4508 or_block_idx_ = nb_i;
4515 row_idx = dec.get_8();
4517 goto process_xor_ref;
4521 row_idx = dec.get_16();
4523 goto process_xor_ref;
4527 row_idx = dec.get_32();
4529 goto process_xor_ref;
4534 unsigned char vbr_flag = dec.get_8();
4537 case 1: row_idx = dec.get_8();
break;
4538 case 2: row_idx = dec.get_16();
break;
4539 case 0: row_idx = dec.get_32();
break;
4542 bm::id64_t acc64 = x_ref_d64_ = dec.get_h64();
4544 xor_chain_size_ = dec.get_8();
4546 for (
unsigned ci = 0; ci < xor_chain_size_; ++ci)
4550 case 1: xor_chain_[ci].ref_idx = dec.get_8();
break;
4551 case 2: xor_chain_[ci].ref_idx = dec.get_16();
break;
4552 case 0: xor_chain_[ci].ref_idx = dec.get_32();
break;
4555 xor_chain_[ci].xor_d64 = dec.get_h64();
4557 BM_ASSERT((xor_chain_[ci].xor_d64 & acc64) == 0);
4558 acc64 |= xor_chain_[ci].xor_d64;
4561 goto process_xor_ref;
4567 throw std::logic_error(this->err_msg());
4569 BM_THROW(BM_ERR_SERIALFORMAT);
4581 bv.set_new_blocks_strat(strat);
4588template<
class BV,
class DEC>
4595 for (
unsigned ci = 0; ci < xor_chain_size_; ++ci)
4597 unsigned ref_idx = (unsigned)ref_vect_->find(xor_chain_[ci].ref_idx);
4607 ref_blk = xor_block_;
4619template<
class BV,
class DEC>
4628 const bvector_type* ref_bv = ref_vect_->get_bv(x_ref_idx_);
4633 ref_blk = ref_bman.get_block_ptr(i0, j0);
4635 BM_ASSERT(!or_block_ || or_block_idx_ == x_nb_);
4641 bm::word_t* blk = bman.deoptimize_block(i0, j0,
true);
4645 alloc_.free_bit_block(or_block_);
4649 bman.set_block_ptr(x_nb_, or_block_);
4651 or_block_ = 0; or_block_idx_ = 0;
4654 if (xor_chain_size_)
4656 bm::word_t* blk = bman.deoptimize_block(i0, j0,
true);
4657 xor_decode_chain(blk);
4668 bm::word_t* blk = bman.get_block_ptr(i0, j0);
4670 if (
BM_IS_GAP(blk) && (x_ref_d64_==~0ULL) && !or_block_)
4681 bman.assign_gap_check(i0, j0, res, ++res_len, blk, tmp_buf);
4688 ref_blk = xor_block_;
4696 bm::word_t* blk = bman.deoptimize_block(i0, j0,
true);
4701 if (xor_chain_size_)
4702 xor_decode_chain(blk);
4714 alloc_.free_bit_block(or_block_);
4727 if (nb_from == x_nb_ || nb_to == x_nb_)
4730 bman.optimize_bit_block(i0, j0, BV::opt_compress);
4735template<
class BV,
class DEC>
4738 x_ref_idx_ = 0; x_ref_d64_ = 0; xor_chain_size_ = 0;
4744template<
typename DEC,
typename BLOCK_IDX>
4748 end_of_stream_(false),
4837 throw std::bad_alloc();
4839 BM_THROW(BM_ERR_BADALLOC);
4846template<
typename DEC,
typename BLOCK_IDX>
4850 ::free(block_idx_arr_);
4854template<
typename DEC,
typename BLOCK_IDX>
4870 end_of_stream_ =
true;
4874 last_id_ = decoder_.get_32();
4881 end_of_stream_ =
true;
4886 block_type_ = decoder_.get_8();
4890 if (block_type_ & (1u << 7u))
4892 mono_block_cnt_ = (block_type_ & ~(1u << 7u)) - 1;
4893 state_ = e_zero_blocks;
4897 switch (block_type_)
4901 end_of_stream_ =
true; state_ = e_unknown;
4904 state_ = e_zero_blocks;
4905 mono_block_cnt_ = 0;
4908 state_ = e_zero_blocks;
4909 mono_block_cnt_ = decoder_.get_8()-1;
4912 state_ = e_zero_blocks;
4913 mono_block_cnt_ = decoder_.get_16()-1;
4916 state_ = e_zero_blocks;
4917 mono_block_cnt_ = decoder_.get_32()-1;
4920 state_ = e_one_blocks;
4924 state_ = e_one_blocks;
4925 mono_block_cnt_ = 0;
4928 state_ = e_one_blocks;
4929 mono_block_cnt_ = decoder_.get_8()-1;
4932 state_ = e_one_blocks;
4933 mono_block_cnt_ = decoder_.get_16()-1;
4936 state_ = e_one_blocks;
4937 mono_block_cnt_ = decoder_.get_32()-1;
4940 state_ = e_one_blocks;
4954 state_ = e_bit_block;
4963 gap_head_ = decoder_.get_16();
4982 state_ = e_gap_block;
4985 state_ = e_gap_block;
4991 this->bookmark_idx_ = block_idx_;
4992 this->skip_offset_ = decoder_.get_32();
4993 this->skip_pos_ = decoder_.get_pos() + this->skip_offset_;
4996 this->bookmark_idx_ = block_idx_;
4997 this->skip_offset_ = decoder_.get_24();
4998 this->skip_pos_ = decoder_.get_pos() + this->skip_offset_;
5001 this->bookmark_idx_ = block_idx_;
5002 this->skip_offset_ = decoder_.get_16();
5003 this->skip_pos_ = decoder_.get_pos() + this->skip_offset_;
5007 nb_sync = decoder_.get_8();
5008 goto process_nb_sync;
5010 nb_sync = decoder_.get_16();
5011 goto process_nb_sync;
5013 nb_sync = decoder_.get_24();
5014 goto process_nb_sync;
5016 nb_sync = decoder_.get_32();
5017 goto process_nb_sync;
5020 goto process_nb_sync;
5024 BM_ASSERT(block_idx_ == this->bookmark_idx_ + nb_sync);
5025 if (block_idx_ != this->bookmark_idx_ + nb_sync)
5028 throw std::logic_error(this->err_msg());
5030 BM_THROW(BM_ERR_SERIALFORMAT);
5057 throw std::logic_error(this->err_msg());
5059 BM_THROW(BM_ERR_SERIALFORMAT);
5068 if (!mono_block_cnt_)
5080 throw std::logic_error(this->err_msg());
5082 BM_THROW(BM_ERR_SERIALFORMAT);
5087template<
typename DEC,
typename BLOCK_IDX>
5091 BM_ASSERT(state_ == e_zero_blocks || state_ == e_one_blocks);
5092 if (!mono_block_cnt_)
5096 block_idx_ += mono_block_cnt_+1;
5097 mono_block_cnt_ = 0;
5103template<
typename DEC,
typename BLOCK_IDX>
5111 for (
unsigned k = 0; k < len; ++k)
5119 for (
unsigned k = 0; k < len; ++k)
5125template<
typename DEC,
typename BLOCK_IDX>
5136 switch (this->block_type_)
5145 unsigned char run_type = decoder_.get_8();
5148 unsigned run_length = decoder_.get_16();
5151 decoder_.get_32(dst_block ? dst_block + j : dst_block, run_length);
5159 unsigned head_idx = decoder_.get_16();
5160 unsigned tail_idx = decoder_.get_16();
5163 for (
unsigned i = 0; i < head_idx; ++i)
5165 decoder_.get_32(dst_block + head_idx,
5166 tail_idx - head_idx + 1);
5172 int pos = int(tail_idx - head_idx) + 1;
5180 get_arr_bit(dst_block,
true );
5185 throw std::logic_error(this->err_msg());
5187 BM_THROW(BM_ERR_SERIALFORMAT);
5191 get_inv_arr(dst_block);
5197 this->read_bic_arr(decoder_, dst_block, this->block_type_);
5200 this->read_bic_arr_inv(decoder_, tmp_block);
5207 this->read_bic_gap(decoder_, dst_block);
5212 this->read_digest0_block(decoder_, dst_block);
5217 throw std::logic_error(this->err_msg());
5219 BM_THROW(BM_ERR_SERIALFORMAT);
5225template<
typename DEC,
typename BLOCK_IDX>
5233 switch (block_type_)
5240 unsigned head_idx = decoder_.get_16();
5241 unsigned tail_idx = decoder_.get_16();
5242 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5243 dst_block[i] |= decoder_.get_32();
5248 unsigned char run_type = decoder_.get_8();
5251 unsigned run_length = decoder_.get_16();
5254 unsigned run_end = j + run_length;
5255 for (;j < run_end; ++j)
5258 dst_block[j] |= decoder_.get_32();
5270 get_arr_bit(dst_block,
false );
5273 get_inv_arr(tmp_block);
5278 this->read_bic_arr(decoder_, dst_block, this->block_type_);
5281 this->read_bic_arr_inv(decoder_, tmp_block);
5285 this->read_bic_gap(decoder_, dst_block);
5288 this->read_digest0_block(decoder_, dst_block);
5293 throw std::logic_error(this->err_msg());
5295 BM_THROW(BM_ERR_SERIALFORMAT);
5301template<
typename DEC,
typename BLOCK_IDX>
5310 switch (block_type_)
5317 unsigned char run_type = decoder_.get_8();
5320 unsigned run_length = decoder_.get_16();
5322 unsigned run_end = j + run_length;
5325 for (;j < run_end; ++j)
5328 dst_block[j] &= decoder_.get_32();
5333 for (;j < run_end; ++j)
5344 unsigned head_idx = decoder_.get_16();
5345 unsigned tail_idx = decoder_.get_16();
5347 for ( i = 0; i < head_idx; ++i)
5349 for ( i = head_idx; i <= tail_idx; ++i)
5350 dst_block[i] &= decoder_.get_32();
5357 get_arr_bit(tmp_block,
true );
5362 get_inv_arr(tmp_block);
5371 this->read_bic_arr(decoder_, tmp_block, block_type_);
5375 this->read_bic_arr(decoder_, 0, block_type_);
5378 this->read_bic_arr_inv(decoder_, tmp_block);
5387 this->read_bic_gap(decoder_, tmp_block);
5391 this->read_bic_gap(decoder_, 0);
5398 this->read_digest0_block(decoder_, tmp_block);
5402 this->read_digest0_block(decoder_, 0);
5407 throw std::logic_error(this->err_msg());
5409 BM_THROW(BM_ERR_SERIALFORMAT);
5415template<
typename DEC,
typename BLOCK_IDX>
5425 switch (block_type_)
5429 dst_block[i] ^= decoder_.get_32();
5433 unsigned char run_type = decoder_.get_8();
5436 unsigned run_length = decoder_.get_16();
5439 unsigned run_end = j + run_length;
5440 for (;j < run_end; ++j)
5443 dst_block[j] ^= decoder_.get_32();
5455 unsigned head_idx = decoder_.get_16();
5456 unsigned tail_idx = decoder_.get_16();
5457 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5458 dst_block[i] ^= decoder_.get_32();
5464 get_arr_bit(tmp_block,
true );
5469 get_inv_arr(tmp_block);
5476 this->read_bic_arr(decoder_, tmp_block, block_type_);
5481 this->read_bic_arr_inv(decoder_, tmp_block);
5493 this->read_bic_gap(decoder_, tmp_block);
5497 this->read_bic_gap(decoder_, 0);
5504 this->read_digest0_block(decoder_, tmp_block);
5508 this->read_digest0_block(decoder_, 0);
5513 throw std::logic_error(this->err_msg());
5515 BM_THROW(BM_ERR_SERIALFORMAT);
5521template<
typename DEC,
typename BLOCK_IDX>
5531 switch (block_type_)
5535 dst_block[i] &= ~decoder_.get_32();
5539 unsigned char run_type = decoder_.get_8();
5542 unsigned run_length = decoder_.get_16();
5545 unsigned run_end = j + run_length;
5546 for (;j < run_end; ++j)
5549 dst_block[j] &= ~~decoder_.get_32();
5561 unsigned head_idx = decoder_.get_16();
5562 unsigned tail_idx = decoder_.get_16();
5563 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5564 dst_block[i] &= ~decoder_.get_32();
5570 get_arr_bit(tmp_block,
true );
5575 get_inv_arr(tmp_block);
5582 this->read_bic_arr(decoder_, tmp_block, block_type_);
5587 this->read_bic_arr_inv(decoder_, tmp_block);
5596 this->read_bic_gap(decoder_, tmp_block);
5600 this->read_bic_gap(decoder_, 0);
5607 this->read_digest0_block(decoder_, tmp_block);
5611 this->read_digest0_block(decoder_, 0);
5616 throw std::logic_error(this->err_msg());
5618 BM_THROW(BM_ERR_SERIALFORMAT);
5625template<
typename DEC,
typename BLOCK_IDX>
5634 switch (block_type_)
5643 unsigned char run_type = decoder_.get_8();
5646 unsigned run_length = decoder_.get_16();
5649 unsigned run_end = j + run_length;
5650 for (;j < run_end; ++j)
5664 unsigned head_idx = decoder_.get_16();
5665 unsigned tail_idx = decoder_.get_16();
5666 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5671 count += get_arr_bit(0);
5678 get_inv_arr(tmp_block);
5683 this->read_bic_arr(decoder_, tmp_block, block_type_);
5686 this->read_bic_arr_inv(decoder_, tmp_block);
5690 this->read_digest0_block(decoder_, tmp_block);
5694 this->read_bic_gap(decoder_, tmp_block);
5701 throw std::logic_error(this->err_msg());
5703 BM_THROW(BM_ERR_SERIALFORMAT);
5710template<
typename DEC,
typename BLOCK_IDX>
5724 switch (block_type_)
5731 unsigned char run_type = decoder_.get_8();
5734 unsigned run_length = decoder_.get_16();
5737 unsigned run_end = j + run_length;
5738 for (;j < run_end; ++j)
5753 unsigned head_idx = decoder_.get_16();
5754 unsigned tail_idx = decoder_.get_16();
5755 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5766 get_inv_arr(tmp_block);
5770 this->read_bic_arr(decoder_, tmp_block, block_type_);
5773 this->read_bic_arr_inv(decoder_, tmp_block);
5776 this->read_bic_gap(decoder_, tmp_block);
5779 this->read_digest0_block(decoder_, 0);
5784 throw std::logic_error(this->err_msg());
5786 BM_THROW(BM_ERR_SERIALFORMAT);
5794template<
typename DEC,
typename BLOCK_IDX>
5804 switch (block_type_)
5813 unsigned char run_type = decoder_.get_8();
5816 unsigned run_length = decoder_.get_16();
5819 unsigned run_end = j + run_length;
5820 for (;j < run_end; ++j)
5834 unsigned head_idx = decoder_.get_16();
5835 unsigned tail_idx = decoder_.get_16();
5836 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5843 get_arr_bit(tmp_block,
true );
5847 get_inv_arr(tmp_block);
5853 this->read_bic_arr(decoder_, tmp_block, block_type_);
5856 this->read_bic_arr_inv(decoder_, tmp_block);
5860 this->read_digest0_block(decoder_, tmp_block);
5864 this->read_bic_gap(decoder_, tmp_block);
5871 throw std::logic_error(this->err_msg());
5873 BM_THROW(BM_ERR_SERIALFORMAT);
5880template<
typename DEC,
typename BLOCK_IDX>
5890 switch (block_type_)
5907 unsigned char run_type = decoder_.get_8();
5910 unsigned run_length = decoder_.get_16();
5911 unsigned run_end = j + run_length;
5914 for (;j < run_end; ++j)
5922 for (;j < run_end; ++j)
5933 unsigned head_idx = decoder_.get_16();
5934 unsigned tail_idx = decoder_.get_16();
5937 for (i = 0; i < head_idx; ++i)
5939 for (i = head_idx; i <= tail_idx; ++i)
5948 get_arr_bit(tmp_block,
true );
5951 get_inv_arr(tmp_block);
5956 this->read_bic_arr(decoder_, tmp_block, block_type_);
5959 this->read_bic_arr_inv(decoder_, tmp_block);
5963 this->read_digest0_block(decoder_, tmp_block);
5967 this->read_bic_gap(decoder_, tmp_block);
5973 throw std::logic_error(this->err_msg());
5975 BM_THROW(BM_ERR_SERIALFORMAT);
5979 return count_adapter.
sum();
5982template<
typename DEC,
typename BLOCK_IDX>
5992 switch (block_type_)
6009 unsigned char run_type = decoder_.get_8();
6012 unsigned run_length = decoder_.get_16();
6013 unsigned run_end = j + run_length;
6016 for (;j < run_end; ++j)
6024 for (;j < run_end; ++j)
6035 unsigned head_idx = decoder_.get_16();
6036 unsigned tail_idx = decoder_.get_16();
6039 for (i = 0; i < head_idx; ++i)
6041 for (i = head_idx; i <= tail_idx; ++i)
6050 get_arr_bit(tmp_block,
true );
6053 get_inv_arr(tmp_block);
6058 this->read_bic_arr(decoder_, tmp_block, block_type_);
6061 this->read_bic_arr_inv(decoder_, tmp_block);
6066 this->read_digest0_block(decoder_, tmp_block);
6070 this->read_bic_gap(decoder_, tmp_block);
6076 throw std::logic_error(this->err_msg());
6078 BM_THROW(BM_ERR_SERIALFORMAT);
6082 return count_adapter.
sum();
6085template<
typename DEC,
typename BLOCK_IDX>
6095 switch (block_type_)
6112 unsigned char run_type = decoder_.get_8();
6115 unsigned run_length = decoder_.get_16();
6116 unsigned run_end = j + run_length;
6119 for (;j < run_end; ++j)
6127 for (;j < run_end; ++j)
6138 unsigned head_idx = decoder_.get_16();
6139 unsigned tail_idx = decoder_.get_16();
6142 for (i = 0; i < head_idx; ++i)
6144 for (i = head_idx; i <= tail_idx; ++i)
6154 get_arr_bit(tmp_block,
true );
6157 get_inv_arr(tmp_block);
6162 this->read_bic_arr(decoder_, tmp_block, block_type_);
6165 this->read_bic_arr_inv(decoder_, tmp_block);
6169 this->read_digest0_block(decoder_, tmp_block);
6173 this->read_bic_gap(decoder_, tmp_block);
6179 throw std::logic_error(this->err_msg());
6181 BM_THROW(BM_ERR_SERIALFORMAT);
6185 return count_adapter.
sum();
6188template<
typename DEC,
typename BLOCK_IDX>
6198 switch (block_type_)
6215 unsigned char run_type = decoder_.get_8();
6218 unsigned run_length = decoder_.get_16();
6219 unsigned run_end = j + run_length;
6222 for (;j < run_end; ++j)
6225 count +=
word_bitcount(decoder_.get_32() & (~dst_block[j]));
6237 unsigned head_idx = decoder_.get_16();
6238 unsigned tail_idx = decoder_.get_16();
6241 for (i = head_idx; i <= tail_idx; ++i)
6249 get_arr_bit(tmp_block,
true );
6252 get_inv_arr(tmp_block);
6257 this->read_bic_arr(decoder_, tmp_block, block_type_);
6260 this->read_bic_arr_inv(decoder_, tmp_block);
6264 this->read_digest0_block(decoder_, tmp_block);
6268 this->read_bic_gap(decoder_, tmp_block);
6274 throw std::logic_error(this->err_msg());
6276 BM_THROW(BM_ERR_SERIALFORMAT);
6279 return count_adapter.
sum();
6284template<
typename DEC,
typename BLOCK_IDX>
6305 for (
unsigned k = 0; k < len; ++k)
6317 decoder_.seek(len * 2);
6322template<
typename DEC,
typename BLOCK_IDX>
6326 ++(this->block_idx_);
6327 this->state_ = e_blocks;
6329 return decoder_.get_16();
6332template<
typename DEC,
typename BLOCK_IDX>
6336 BM_ASSERT(this->state_ == e_gap_block ||
6340 this->read_gap_block(this->decoder_,
6345 ++(this->block_idx_);
6346 this->state_ = e_blocks;
6350template<
typename DEC,
typename BLOCK_IDX>
6359 get_bit_func_type bit_func = bit_func_table_[op];
6361 unsigned cnt = ((*this).*(bit_func))(dst_block, tmp_block);
6362 this->state_ = e_blocks;
6363 ++(this->block_idx_);
6374: temp_block_(0), ref_vect_(0)
6376 temp_block_ = alloc_.alloc_bit_block();
6384 alloc_.free_bit_block(temp_block_);
6396 typename BV::size_type count = 0;
6400 bv.bit_and(bv_tmp, BV::opt_compress);
6415 count = bv_tmp.count();
6441 BM_THROW(BM_ERR_SERIALFORMAT);
6451operation_deserializer<BV>::deserialize_xor(
bvector_type& bv,
6452 const unsigned char* buf,
6463 return deserialize_xor(bv, bv_tmp, op);
6467void operation_deserializer<BV>::deserialize_xor_range(
6469 const unsigned char* buf,
6478 unsigned char header_flag = dec.get_8();
6485 if (bo_current == bo)
6487 de_.set_ref_vectors(ref_vect_);
6488 de_.set_range(idx_from, idx_to);
6489 de_.deserialize(bv, buf);
6498 deserializer<BV, bm::decoder_big_endian> deserial;
6499 deserial.set_ref_vectors(ref_vect_);
6500 deserial.set_range(idx_from, idx_to);
6501 deserial.deserialize(bv, buf);
6506 deserializer<BV, bm::decoder_little_endian> deserial;
6507 deserial.set_ref_vectors(ref_vect_);
6508 deserial.set_range(idx_from, idx_to);
6509 deserial.deserialize(bv, buf);
6516 bv.keep_range_no_check(idx_from, idx_to);
6523operation_deserializer<BV>::deserialize_xor(
bvector_type& bv,
6527 size_type count = 0;
6543 count = bv_tmp.
count();
6566 throw std::logic_error(
"BM: serialization error");
6568 BM_THROW(BM_ERR_SERIALFORMAT);
6580 const unsigned char* buf,
6586 unsigned char header_flag = dec.
get_8();
6591 return deserialize_xor(bv, buf, op, exit_on_one);
6607 if (bo_current == bo)
6612 de_.deserialize(bv, buf);
6616 bv_tmp_.clear(
true);
6619 de_.deserialize(bv_tmp_, buf);
6631 if (bo_current == bo)
6634 return it_d_.deserialize(bv, ss, temp_block_, op, exit_on_one);
6641 return it_d_be_.deserialize(bv, ss, temp_block_, op, exit_on_one);
6646 return it_d_le_.deserialize(bv, ss, temp_block_, op, exit_on_one);
6651 throw std::logic_error(
"BM::platform error: unknown endianness");
6653 BM_THROW(BM_ERR_SERIALFORMAT);
6661 const unsigned char* buf,
6667 unsigned char header_flag = dec.
get_8();
6674 blocks_manager_type& bman = bv.get_blocks_manager();
6675 if (!bman.is_init())
6676 bv.set_range(idx_from, idx_to);
6685 deserialize_xor_range(bv_tmp, buf, idx_from, idx_to);
6699 if (bo_current == bo)
6701 bv_tmp_.clear(
true);
6704 de_.set_range(idx_from, idx_to);
6705 de_.deserialize(bv_tmp_, buf);
6728 if (bo_current == bo)
6731 it_d_.set_range(idx_from, idx_to);
6732 it_d_.deserialize(bv, ss, temp_block_, op,
false);
6733 it_d_.unset_range();
6741 it_d_be_.set_range(idx_from, idx_to);
6742 it_d_be_.deserialize(bv, ss, temp_block_, op,
false);
6743 it_d_be_.unset_range();
6749 it_d_le_.set_range(idx_from, idx_to);
6750 it_d_le_.deserialize(bv, ss, temp_block_, op,
false);
6751 it_d_le_.unset_range();
6757 throw std::logic_error(
"BM::platform error: unknown endianness");
6759 BM_THROW(BM_ERR_SERIALFORMAT);
6769template<
class BV,
class SerialIterator>
6773 is_range_set_ =
true;
6779template<
class BV,
class SerialIterator>
6782 serial_iterator_type& sit,
6786 const unsigned win_size = 64;
6791 for (
unsigned i = 0; i <= id_count;)
6794 for (j = 0; j < win_size && i <= id_count; ++j, ++i)
6796 id_buffer[j] = sit.get_id();
6804 for (
unsigned i = 0; i <= id_count;)
6807 for (j = 0; j < win_size && i <= id_count; ++j, ++i)
6809 id_buffer[j] = sit.get_id();
6817template<
class BV,
class SerialIterator>
6819iterator_deserializer<BV, SerialIterator>::finalize_target_vector(
6820 blocks_manager_type& bman,
6822 size_type bv_block_idx)
6824 size_type count = 0;
6835 if (bv_block_idx <= nblock_last)
6836 bman.set_all_zero(bv_block_idx, nblock_last);
6845 bm::word_t*** blk_root = bman.top_blocks_root();
6846 unsigned top_size = bman.top_block_size();
6847 for (;i < top_size; ++i)
6860 count += bman.block_bitcount(blk_blk[j]);
6870 throw std::logic_error(err_msg());
6872 BM_THROW(BM_ERR_SERIALFORMAT);
6878template<
class BV,
class SerialIterator>
6880iterator_deserializer<BV, SerialIterator>::process_id_list(
6882 serial_iterator_type& sit,
6885 size_type count = 0;
6886 unsigned id_count = sit.get_id_count();
6887 bool set_clear =
true;
6894 load_id_list(bv_tmp, sit, id_count,
true);
6907 load_id_list(bv, sit, id_count, set_clear);
6910 for (
unsigned i = 0; i < id_count; ++i)
6918 for (
unsigned i = 0; i < id_count; ++i)
6928 for (size_type i = 0; i < id_count; ++i)
6939 load_id_list(bv_tmp, sit, id_count,
true);
6947 load_id_list(bv_tmp, sit, id_count,
true);
6955 load_id_list(bv_tmp, sit, id_count,
false);
6956 count += bv_tmp.
count();
6962 load_id_list(bv_tmp, sit, id_count,
true);
6970 throw std::logic_error(err_msg());
6972 BM_THROW(BM_ERR_SERIALFORMAT);
6980template<
class BV,
class SerialIterator>
6993 gap_temp_block[0] = 0;
6995 blocks_manager_type& bman = bv.get_blocks_manager();
6996 if (!bman.is_init())
6999 if (sit.bv_size() && (sit.bv_size() > bv.size()))
7000 bv.resize(sit.bv_size());
7002 typename serial_iterator_type::iterator_state state;
7003 state = sit.get_state();
7004 if (state == serial_iterator_type::e_list_ids)
7006 count = process_id_list(bv, sit, op);
7018 count += finalize_target_vector(bman, op, bv_block_idx);
7022 state = sit.state();
7025 case serial_iterator_type::e_blocks:
7030 if (is_range_set_ && (bv_block_idx < nb_range_from_))
7033 bool skip_flag = sit.try_skip(bv_block_idx, nb_range_from_);
7036 bv_block_idx = sit.block_idx();
7037 BM_ASSERT(bv_block_idx <= nb_range_from_);
7038 BM_ASSERT(sit.state() == serial_iterator_type::e_blocks);
7042 case serial_iterator_type::e_bit_block:
7044 BM_ASSERT(sit.block_idx() == bv_block_idx);
7047 bm::word_t* blk = bman.get_block_ptr(i0, j0);
7060 blk = bman.make_bit_block(bv_block_idx);
7073 throw std::logic_error(err_msg());
7075 BM_THROW(BM_ERR_SERIALFORMAT);
7092 blk = bman.deoptimize_block(bv_block_idx);
7098 unsigned c = sit.get_bit_block(blk, temp_block, sop);
7100 if (exit_on_one && count)
7113 case serial_iterator_type::e_zero_blocks:
7115 BM_ASSERT(bv_block_idx == sit.block_idx());
7122 bv_block_idx = sit.skip_mono_blocks();
7128 bv_block_idx = sit.skip_mono_blocks();
7129 bman.set_all_zero(nb_start, bv_block_idx-1);
7140 bm::word_t* blk = bman.get_block_ptr(i0, j0);
7151 bman.zero_block(bv_block_idx);
7165 count += blk ? bman.block_bitcount(blk) : 0;
7166 if (exit_on_one && count)
7178 case serial_iterator_type::e_one_blocks:
7180 BM_ASSERT(bv_block_idx == sit.block_idx());
7183 bm::word_t* blk = bman.get_block_ptr(i0, j0);
7190 bman.set_block_all_set(bv_block_idx);
7198 bman.zero_block(bv_block_idx);
7202 if (++empty_op_cnt > 64)
7205 bool b = bv.find_reverse(last_id);
7209 if (last_nb < bv_block_idx)
7215 count += blk ? bman.block_bitcount(blk) : 0;
7223 blk = bman.deoptimize_block(bv_block_idx);
7254 bman.set_block_all_set(bv_block_idx);
7268 if (exit_on_one && count)
7273 case serial_iterator_type::e_gap_block:
7275 BM_ASSERT(bv_block_idx == sit.block_idx());
7279 const bm::word_t* blk = bman.get_block(i0, j0);
7281 sit.get_gap_block(gap_temp_block);
7299 if (exit_on_one && count)
7307 bman.zero_block(bv_block_idx);
7318 bv_block_idx, gap_temp_block, level);
7331 bv.combine_operation_with_block(bv_block_idx,
7339 bv.combine_operation_with_block(
7349 blk = bman.get_block_ptr(i0, j0);
7365 throw std::logic_error(err_msg());
7367 BM_THROW(BM_ERR_SERIALFORMAT);
7374 if (is_range_set_ && (bv_block_idx > nb_range_to_))
7388#pragma warning( pop )
Algorithms for bvector<> (main include)
#define IS_FULL_BLOCK(addr)
#define IS_VALID_ADDR(addr)
#define BMPTR_SETBIT0(ptr)
#define BMSET_PTRGAP(ptr)
#define FULL_BLOCK_FAKE_ADDR
#define FULL_BLOCK_REAL_ADDR
Bit manipulation primitives (internal)
#define BM_SER_NEXT_GRP(enc, nb, B_1ZERO, B_8ZERO, B_16ZERO, B_32ZERO, B_64ZERO)
Utilities for bit transposition (internal) (experimental!)
Bit manipulation primitives (internal)
Functions and utilities for XOR filters (internal)
Byte based reader for un-aligned bit streaming.
unsigned gamma() BMNOEXCEPT
decode unsigned value using Elias Gamma coding
void bic_decode_u16(bm::gap_word_t *arr, unsigned sz, bm::gap_word_t lo, bm::gap_word_t hi) BMNOEXCEPT
Binary Interpolative array decode.
void bic_decode_u16_bitset(bm::word_t *block, unsigned sz, bm::gap_word_t lo, bm::gap_word_t hi) BMNOEXCEPT
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)
void bic_decode_u16_dry(unsigned sz, bm::gap_word_t lo, bm::gap_word_t hi) BMNOEXCEPT
Byte based writer for un-aligned bit streaming.
void flush() BMNOEXCEPT
Flush the incomplete 32-bit accumulator word.
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.
void bic_encode_u16(const bm::gap_word_t *arr, unsigned sz, bm::gap_word_t lo, bm::gap_word_t hi) BMNOEXCEPT
Binary Interpolative array decode.
Bit-block get adapter, takes bitblock and represents it as a get_32() accessor function.
Bit-block sum adapter, takes values and sums it /internal.
bm::word_t sum() const BMNOEXCEPT
Get accumulated sum.
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)
size_type count() const BMNOEXCEPT
population count (count of ON bits)
bm::bvector< Alloc > & bit_and(const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode=opt_none)
3-operand AND : this := bv1 AND bv2
blocks_manager< Alloc > blocks_manager_type
bvector_size_type size_type
void swap(bvector< Alloc > &bvect) BMNOEXCEPT
Exchanges content of bv and this bvector.
blocks_manager_type::block_idx_type block_idx_type
void clear(const size_type *ids, size_type ids_size, bm::sort_order so=bm::BM_UNKNOWN)
clear list of bits in this bitset
bool get_bit(size_type n) const BMNOEXCEPT
returns true if bit n is set and false is bit n is 0.
const unsigned char * get_pos() const BMNOEXCEPT
Return current buffer pointer.
unsigned char get_8() BMNOEXCEPT
Reads character from the decoding buffer.
void set_pos(const unsigned char *pos) BMNOEXCEPT
Set current buffer pointer.
Class for decoding data from memory buffer.
bm::word_t get_32() BMNOEXCEPT
Reads 32-bit word from the decoding buffer.
bm::word_t get_24() 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.
bm::id64_t get_48() BMNOEXCEPT
Reads 64-bit word from the decoding buffer.
Base deserialization class.
const unsigned char * skip_pos_
decoder skip position
static const char * err_msg() BMNOEXCEPT
block_idx_type bookmark_idx_
last bookmark block index
unsigned skip_offset_
bookmark to skip 256 encoded blocks
static void read_0runs_block(decoder_type &decoder, bm::word_t *blk) BMNOEXCEPT
read bit-block encoded as runs
void read_bic_arr_inv(decoder_type &decoder, bm::word_t *blk) BMNOEXCEPT
Read inverted binary interpolated list into a bit-set.
block_idx_type try_skip(decoder_type &decoder, block_idx_type nb, block_idx_type expect_nb) BMNOEXCEPT
Try to skip if skip bookmark is available within reach.
void read_digest0_block(decoder_type &decoder, bm::word_t *blk) BMNOEXCEPT
Read digest0-type bit-block.
void read_bic_gap(decoder_type &decoder, bm::word_t *blk) BMNOEXCEPT
Read binary interpolated gap blocks into a bitset.
bm::bit_in< DEC > bit_in_type
unsigned * sb_id_array_
ptr to super-block idx array (temp)
unsigned read_bic_sb_arr(decoder_type &decoder, unsigned block_type, unsigned *dst_arr, unsigned *sb_idx)
Read list of bit ids for super-blocks.
void read_gap_block(decoder_type &decoder, unsigned block_type, bm::gap_word_t *dst_block, bm::gap_word_t &gap_head)
Read GAP block from the stream.
unsigned read_id_list(decoder_type &decoder, unsigned block_type, bm::gap_word_t *dst_arr)
Read list of bit ids.
bm::gap_word_t * id_array_
ptr to idx array for temp decode use
void read_bic_arr(decoder_type &decoder, bm::word_t *blk, unsigned block_type) BMNOEXCEPT
Read binary interpolated list into a bit-set.
Deserializer for bit-vector.
void reset() BMNOEXCEPT
reset range deserialization and reference vectors
void set_ref_vectors(const bv_ref_vector_type *ref_vect)
Attach collection of reference vectors for XOR de-serialization (no transfer of ownership for the poi...
bm::match_pair xor_chain_[64]
block_arridx_type bit_idx_arr_
allocator_type::allocator_pool_type allocator_pool_type
void xor_decode(blocks_manager_type &bman)
deseriaizer_base< DEC, block_idx_type > parent_type
bm::bv_ref_vector< BV > bv_ref_vector_type
void decode_arr_sblock(unsigned char btype, decoder_type &dec, bvector_type &bv)
void deserialize_gap(unsigned char btype, decoder_type &dec, bvector_type &bv, blocks_manager_type &bman, block_idx_type nb, bm::word_t *blk)
bvector_type::allocator_type allocator_type
parent_type::decoder_type decoder_type
void xor_reset() BMNOEXCEPT
void set_range(size_type from, size_type to) BMNOEXCEPT
set deserialization range [from, to] This is NOT exact, approximate range, content outside range is n...
allocator_pool_type pool_
sblock_arridx_type sb_bit_idx_arr_
const bv_ref_vector_type * ref_vect_
ref.vector for XOR compression
void unset_range() BMNOEXCEPT
Disable range deserialization.
BV::blocks_manager_type blocks_manager_type
block_arridx_type gap_temp_block_
bm::word_t * xor_block_
xor product
size_t deserialize(bvector_type &bv, const unsigned char *buf, bm::word_t *temp_block=0)
bvector_type::block_idx_type block_idx_type
void decode_arrbit(decoder_type &dec, bvector_type &bv, block_idx_type nb, bm::word_t *blk)
void xor_decode_chain(bm::word_t *BMRESTRICT blk) BMNOEXCEPT
void decode_bit_block(unsigned char btype, decoder_type &dec, blocks_manager_type &bman, block_idx_type nb, bm::word_t *blk)
void decode_block_bit(decoder_type &dec, bvector_type &bv, block_idx_type nb, bm::word_t *blk)
void decode_block_bit_interval(decoder_type &dec, bvector_type &bv, block_idx_type nb, bm::word_t *blk)
bm::heap_vector< bm::gap_word_t, allocator_type, true > block_arridx_type
bm::heap_vector< bm::word_t, allocator_type, true > sblock_arridx_type
unsigned char * position_type
size_t size() const BMNOEXCEPT
Returns size of the current encoding stream.
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 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.
void put_prefixed_array_32(unsigned char c, const bm::word_t *w, unsigned count) BMNOEXCEPT
Encode 8-bit prefix + an array.
void put_8_16_32(unsigned w, unsigned char c8, unsigned char c16, unsigned char c32) BMNOEXCEPT
but gat plus value based on its VBR evaluation
Functor for Elias Gamma encoding.
Iterator to walk forward the serialized stream.
void set_range(size_type from, size_type to)
set deserialization range [from, to]
SerialIterator serial_iterator_type
void unset_range() BMNOEXCEPT
disable range filtration
bvector_type::size_type size_type
size_type deserialize(bvector_type &bv, serial_iterator_type &sit, bm::word_t *temp_block, set_operation op=bm::set_OR, bool exit_on_one=false)
Deserializer, performs logical operations between bit-vector and serialized bit-vector.
bm::bv_ref_vector< BV > bv_ref_vector_type
void set_ref_vectors(const bv_ref_vector_type *ref_vect)
Attach collection of reference vectors for XOR serialization (no transfer of ownership for the pointe...
void deserialize_range(bvector_type &bv, const unsigned char *buf, size_type idx_from, size_type idx_to)
BV::allocator_type allocator_type
~operation_deserializer()
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.
void deserialize_range(bvector_type &bv, const unsigned char *buf, bm::word_t *, size_type idx_from, size_type idx_to)
bvector_type::size_type size_type
size_type deserialize(bvector_type &bv, const unsigned char *buf, bm::word_t *, set_operation op=bm::set_OR, bool exit_on_one=false)
Obsolete! Deserialize bvector using buffer as set operation argument.
Serialization stream iterator.
unsigned get_arr_bit(bm::word_t *dst_block, bool clear_target=true) BMNOEXCEPT
Get array of bits out of the decoder into bit block (Converts inverted list into bits) Returns number...
bm::id_t last_id_
Last id from the id list.
unsigned get_bit_block_COUNT_B(bm::word_t *dst_block, bm::word_t *tmp_block)
deseriaizer_base< DEC, block_idx_type > parent_type
deseriaizer_base< DEC, BLOCK_IDX >::decoder_type decoder_type
unsigned char header_flag_
decoder_type & decoder()
Get low level access to the decoder (use carefully)
void next()
get next block
serial_stream_iterator(const unsigned char *buf)
block_idx_type mono_block_cnt_
number of 0 or 1 blocks
unsigned block_type_
current block type
unsigned get_id_count() const BMNOEXCEPT
Number of ids in the inverted list (valid for e_list_ids)
unsigned get_bit() BMNOEXCEPT
unsigned get_bit_block_SUB(bm::word_t *dst_block, bm::word_t *tmp_block)
void get_inv_arr(bm::word_t *block) BMNOEXCEPT
unsigned get_bit_block_COUNT_SUB_AB(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_bit_block_AND(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_bit_block_COUNT_SUB_BA(bm::word_t *dst_block, bm::word_t *tmp_block)
bm::id_t get_id() const BMNOEXCEPT
Get last id from the id list.
unsigned get_bit_block_COUNT_OR(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_bit_block_COUNT(bm::word_t *dst_block, bm::word_t *tmp_block)
bool is_eof() const
Returns true if end of bit-stream reached.
block_idx_type block_idx_
current block index
unsigned get_bit_block_XOR(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_bit_block_OR(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_bit_block_ASSIGN(bm::word_t *dst_block, bm::word_t *tmp_block)
iterator_state state() const BMNOEXCEPT
Returns iterator internal state.
block_idx_type block_idx() const BMNOEXCEPT
Get current block index.
gap_word_t * block_idx_arr_
unsigned get_bit_block_COUNT_A(bm::word_t *dst_block, bm::word_t *tmp_block)
~serial_stream_iterator()
gap_word_t glevels_[bm::gap_levels]
GAP levels.
iterator_state
iterator is a state machine, this enum encodes its key value
@ e_bit_block
one bit block
@ e_list_ids
plain int array
@ e_zero_blocks
one or more zero bit blocks
@ e_one_blocks
one or more all-1 bit blocks
@ e_blocks
stream of blocks
void get_gap_block(bm::gap_word_t *dst_block)
Read gap block data (with head)
get_bit_func_type bit_func_table_[bm::set_END]
unsigned id_cnt_
Id counter for id list.
unsigned get_bit_block_COUNT_XOR(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_bit_block_COUNT_AND(bm::word_t *dst_block, bm::word_t *tmp_block)
block_idx_type skip_mono_blocks() BMNOEXCEPT
skip all zero or all-one blocks
block_idx_type bv_size() const
serialized bitvector size
iterator_state get_state() const BMNOEXCEPT
unsigned get_bit_block(bm::word_t *dst_block, bm::word_t *tmp_block, set_operation op)
read bit block, using logical operation
Bit-vector serialization class.
void gamma_gap_block(const bm::gap_word_t *gap_block, bm::encoder &enc) BMNOEXCEPT
void serialize(const BV &bv, typename serializer< BV >::buffer &buf, const statistics_type *bv_stat=0)
Bitvector serialization into buffer object (resized automatically)
unsigned char find_bit_best_encoding(const bm::word_t *block) BMNOEXCEPT
Determine best representation for a bit-block.
serializer(bm::word_t *temp_block)
void reset_compression_stats() BMNOEXCEPT
Reset all accumulated compression statistics.
void bienc_arr_sblock(const BV &bv, unsigned sb, bm::encoder &enc) BMNOEXCEPT
void xor_tmp_product(const bm::word_t *s_block, const block_match_chain_type &mchain, unsigned i, unsigned j) BMNOEXCEPT
Compute digest based XOR product, place into tmp XOR block.
void gap_length_serialization(bool value) BMNOEXCEPT
Set GAP length serialization (serializes GAP levels of the original vector)
void set_sim_model(const xor_sim_model_type *sim_model) BMNOEXCEPT
Atach XOR similarity model (must be computed by the same ref vector)
bvector_type::block_idx_type block_idx_type
bvector_type::size_type size_type
unsigned char find_gap_best_encoding(const bm::gap_word_t *gap_block) BMNOEXCEPT
Determine best representation for GAP block based on current set compression level.
void gamma_arr_bit_block(const bm::word_t *block, bm::encoder &enc, bool inverted) BMNOEXCEPT
void set_curr_ref_idx(size_type ref_idx) BMNOEXCEPT
Set current index in rer.vector collection (not a row idx or plain idx)
void interpolated_gap_array_v0(const bm::gap_word_t *gap_block, unsigned arr_len, bm::encoder &enc, bool inverted) BMNOEXCEPT
void set_compression_level(unsigned clevel) BMNOEXCEPT
Set compression level.
void allow_stat_reset(bool allow) BMNOEXCEPT
Enable/disable statistics reset on each serilaization.
void encode_bit_digest(const bm::word_t *blk, bm::encoder &enc, bm::id64_t d0) BMNOEXCEPT
Encode bit-block using digest (hierarchical compression)
bm::bv_ref_vector< BV > bv_ref_vector_type
void byte_order_serialization(bool value) BMNOEXCEPT
Set byte-order serialization (for cross platform compatibility)
unsigned char find_bit_best_encoding_l5(const bm::word_t *block) BMNOEXCEPT
Determine best representation for a bit-block (level 5)
void set_sparse_cutoff(unsigned cutoff) BMNOEXCEPT
Fine tuning for Binary Interpolative Compression (levels 5+) The parameter sets average population co...
void optimize_serialize_destroy(BV &bv, typename serializer< BV >::buffer &buf)
Bitvector serialization into buffer object (resized automatically) Input bit-vector gets optimized an...
bvector_type::allocator_type allocator_type
byte_buffer< allocator_type > buffer
bool 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.
void encode_bit_array(const bm::word_t *block, bm::encoder &enc, bool inverted) BMNOEXCEPT
Encode bit-block as an array of bits.
void interpolated_gap_bit_block(const bm::word_t *block, bm::encoder &enc) BMNOEXCEPT
encode bit-block as interpolated gap block
bvector_type::blocks_manager_type blocks_manager_type
void encode_gap_block(const bm::gap_word_t *gap_block, bm::encoder &enc)
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...
unsigned get_compression_level() const BMNOEXCEPT
Get current compression level.
void reset_models() BMNOEXCEPT
void encode_xor_match_chain(bm::encoder &enc, const block_match_chain_type &mchain) BMNOEXCEPT
Encode XOR match chain.
xor_sim_model_type::block_match_chain_type block_match_chain_type
static void process_bookmark(block_idx_type nb, bookmark_state &bookm, bm::encoder &enc) BMNOEXCEPT
Check if bookmark needs to be placed and if so, encode it into serialization BLOB.
serializer(const allocator_type &alloc=allocator_type(), bm::word_t *temp_block=0)
Constructor.
void interpolated_arr_bit_block(const bm::word_t *block, bm::encoder &enc, bool inverted) BMNOEXCEPT
void interpolated_gap_array(const bm::gap_word_t *gap_block, unsigned arr_len, bm::encoder &enc, bool inverted) BMNOEXCEPT
Encode GAP block as an array with binary interpolated coder.
bm::xor_sim_model< BV > xor_sim_model_type
void gamma_gap_array(const bm::gap_word_t *gap_block, unsigned arr_len, bm::encoder &enc, bool inverted=false) BMNOEXCEPT
Encode GAP block as delta-array with Elias Gamma coder.
const size_type * get_compression_stat() const BMNOEXCEPT
Return serialization counter vector.
void add_model(unsigned char mod, unsigned score) BMNOEXCEPT
void bienc_gap_bit_block(const bm::word_t *block, bm::encoder &enc) BMNOEXCEPT
encode bit-block as interpolated bit block of gaps
void gamma_gap_bit_block(const bm::word_t *block, bm::encoder &enc) BMNOEXCEPT
bvector_type::statistics statistics_type
void set_ref_vectors(const bv_ref_vector_type *ref_vect)
Attach collection of reference vectors for XOR serialization (no transfer of ownership for the pointe...
void encode_bit_interval(const bm::word_t *blk, bm::encoder &enc, unsigned size_control) BMNOEXCEPT
Encode BIT block with repeatable runs of zeroes.
void interpolated_encode_gap_block(const bm::gap_word_t *gap_block, bm::encoder &enc) BMNOEXCEPT
size_type serialize(const BV &bv, unsigned char *buf, size_t buf_size)
Bitvector serialization into memory block.
void encode_header(const BV &bv, bm::encoder &enc) BMNOEXCEPT
Encode serialization header information.
void bienc_arr_bit_block(const bm::word_t *block, bm::encoder &enc, bool inverted) BMNOEXCEPT
XOR scanner to search for complement-similarities in collections of bit-vectors.
Encoding utilities for serialization (internal)
unsigned bit_block_find(const bm::word_t *BMRESTRICT block, unsigned nbit, unsigned *BMRESTRICT pos) BMNOEXCEPT
Searches for the next 1 bit in the BIT block.
BMFORCEINLINE bm::id_t word_bitcount(bm::id_t w) BMNOEXCEPT
void bit_block_copy(bm::word_t *BMRESTRICT dst, const bm::word_t *BMRESTRICT src) BMNOEXCEPT
Bitblock copy operation.
unsigned bit_count_nonzero_size(const T *blk, unsigned data_size) BMNOEXCEPT
Inspects block for full zero words.
bm::id64_t bit_block_and(bm::word_t *BMRESTRICT dst, const bm::word_t *BMRESTRICT src) BMNOEXCEPT
Plain bitblock AND operation. Function does not analyse availability of source and destination blocks...
bm::id_t bit_block_count(const bm::word_t *block) BMNOEXCEPT
Bitcount for bit block.
BMFORCEINLINE void clear_bit(unsigned *dest, unsigned bitpos) BMNOEXCEPT
Set 1 bit in a block.
bm::set_representation best_representation(unsigned bit_count, unsigned total_possible_bitcount, unsigned gap_count, unsigned block_size) BMNOEXCEPT
Choose best representation for a bit-block.
bm::id_t bit_operation_or_count(const bm::word_t *BMRESTRICT src1, const bm::word_t *BMRESTRICT src2) BMNOEXCEPT
Performs bitblock OR operation and calculates bitcount of the result.
BMFORCEINLINE unsigned word_bitcount64(bm::id64_t x) BMNOEXCEPT
BMFORCEINLINE void set_bit(unsigned *dest, unsigned bitpos) BMNOEXCEPT
Set 1 bit in a block.
unsigned bit_block_convert_to_arr(T *BMRESTRICT dest, const unsigned *BMRESTRICT src, bool inverted) BMNOEXCEPT
Convert bit block into an array of ints corresponding to 1 bits.
bm::id64_t calc_block_digest0(const bm::word_t *const block) BMNOEXCEPT
Compute digest for 64 non-zero areas.
void bit_invert(T *start) BMNOEXCEPT
bm::id64_t bit_block_xor(bm::word_t *BMRESTRICT dst, const bm::word_t *BMRESTRICT src) BMNOEXCEPT
Plain bitblock XOR operation. Function does not analyse availability of source and destination blocks...
void bit_block_set(bm::word_t *BMRESTRICT dst, bm::word_t value) BMNOEXCEPT
Bitblock memset operation.
bool bit_block_or(bm::word_t *BMRESTRICT dst, const bm::word_t *BMRESTRICT src) BMNOEXCEPT
Plain bitblock OR operation. Function does not analyse availability of source and destination blocks.
bm::id_t bit_operation_xor_count(const bm::word_t *BMRESTRICT src1, const bm::word_t *BMRESTRICT src2) BMNOEXCEPT
Performs bitblock XOR operation and calculates bitcount of the result.
bm::id64_t bit_block_sub(bm::word_t *BMRESTRICT dst, const bm::word_t *BMRESTRICT src) BMNOEXCEPT
Plain bitblock SUB (AND NOT) operation. Function does not analyse availability of source and destinat...
bm::id_t bit_operation_and_count(const bm::word_t *BMRESTRICT src1, const bm::word_t *BMRESTRICT src2) BMNOEXCEPT
Performs bitblock AND operation and calculates bitcount of the result.
bm::id_t bit_operation_sub_count(const bm::word_t *BMRESTRICT src1, const bm::word_t *BMRESTRICT src2) BMNOEXCEPT
Performs bitblock SUB operation and calculates bitcount of the result.
bm::alloc_pool_guard< allocator_pool_type, bvector< Alloc > > mem_pool_guard
set_operation
Codes of set operations.
strategy
Block allocation strategies.
@ BM_GAP
GAP compression is ON.
size_t serialize(const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
Saves bitvector into memory.
serialization_flags
Bit mask flags for serialization algorithm <>
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 deserialize_range(BV &bv, const unsigned char *buf, typename BV::size_type from, typename BV::size_type to, const bm::bv_ref_vector< BV > *ref_vect=0)
Bitvector range deserialization from a memory BLOB.
@ BM_NO_GAP_LENGTH
save no GAP info (save some space)
@ BM_NO_BYTE_ORDER
save no byte-order info (save some space)
distance_metric
Distance metrics codes defined for vectors A and B.
distance_metric operation2metric(set_operation op) BMNOEXCEPT
Convert set operation into compatible distance metric.
@ COUNT_XOR
(A ^ B).count()
@ COUNT_SUB_BA
(B - A).count()
unsigned gap_bit_count_unr(const T *buf) BMNOEXCEPT
Calculates number of bits ON in GAP buffer. Loop unrolled version.
D gap_convert_to_arr(D *BMRESTRICT dest, const T *BMRESTRICT buf, unsigned dest_len, bool invert=false) BMNOEXCEPT
Convert gap block into array of ints corresponding to 1 bits.
gap_word_t * gap_operation_xor(const gap_word_t *BMRESTRICT vect1, const gap_word_t *BMRESTRICT vect2, gap_word_t *BMRESTRICT tmp_buf, unsigned &dsize) BMNOEXCEPT
GAP XOR operation.
void gap_convert_to_bitset(unsigned *BMRESTRICT dest, const T *BMRESTRICT buf, unsigned len=0) BMNOEXCEPT
GAP block to bitblock conversion.
void gap_invert(T *buf) BMNOEXCEPT
Inverts all bits in the GAP buffer.
unsigned gap_set_array(T *buf, const T *arr, unsigned len) BMNOEXCEPT
Convert array to GAP buffer.
void set_gap_level(T *buf, int level) BMNOEXCEPT
Sets GAP block capacity level.
void gap_add_to_bitset(unsigned *BMRESTRICT dest, const T *BMRESTRICT pcurr, unsigned len) BMNOEXCEPT
Adds(OR) GAP block to bitblock.
void gap_set_all(T *buf, unsigned set_max, unsigned value) BMNOEXCEPT
Sets all bits to 0 or 1 (GAP)
unsigned gap_add_value(T *buf, unsigned pos) BMNOEXCEPT
Add new value to the end of GAP buffer.
int gap_calc_level(unsigned len, const T *glevel_len) BMNOEXCEPT
Calculates GAP block capacity level.
BMFORCEINLINE bm::gap_word_t gap_length(const bm::gap_word_t *BMRESTRICT buf) BMNOEXCEPT
Returs GAP block length.
void combine_sub(BV &bv, It first, It last)
SUB Combine bitvector and the iterable sequence.
BV::size_type count_and(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of AND operation of two bitsets.
BV::size_type count_or(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of OR operation of two bitsets.
BV::size_type count_sub(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of SUB operation of two bitsets.
void combine_or(BV &bv, It first, It last)
OR Combine bitvector and the iterable sequence.
bm::distance_metric_descriptor::size_type count_xor(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of XOR operation of two bitsets.
const unsigned char set_block_ref_eq
block is a copy of a reference block
const unsigned char set_block_xor_ref32_um
..... 32-bit (should never happen)
const unsigned set_block_digest_wave_size
const unsigned char set_block_gap
Plain GAP block.
BV::size_type process_operation(BV &bv, BV &bv_tmp, bm::set_operation op)
Utility function to process operation using temp vector.
void bit_block_change_bc(const bm::word_t *BMRESTRICT block, unsigned *BMRESTRICT gc, unsigned *BMRESTRICT bc) BMNOEXCEPT
const unsigned char set_block_arrbit_inv
List of bits OFF.
const unsigned char set_nb_sync_mark8
bookmark sync point (8-bits)
const unsigned sblock_flag_max16
const unsigned sblock_flag_sb16
16-bit SB index (8-bit by default)
const unsigned char set_block_bit_interval
Interval block.
bool check_block_zero(const bm::word_t *blk, bool deep_scan) BMNOEXCEPT
Checks all conditions and returns true if block consists of only 0 bits.
const unsigned char set_block_bit_digest0
H-compression with digest mask.
const unsigned char set_block_xor_ref32
..... 32-bit (should never happen)
const unsigned char set_block_arrgap_bienc_inv_v2
Interpolated GAP array (inverted)
const unsigned char set_block_bitgap_bienc
Interpolated bit-block as GAPs.
unsigned char check_pair_vect_vbr(const BMChain &mchain, const RVect &ref_vect)
Check effective bit-rate for the XOR encode vector.
const unsigned char set_block_arrgap_egamma_inv
Gamma compressed inverted delta GAP array.
bool check_block_one(const bm::word_t *blk, bool deep_scan) BMNOEXCEPT
Checks if block has only 1 bits.
const unsigned char set_block_arr_bienc_inv
Interpolated inverted block int array.
unsigned bit_to_gap(gap_word_t *BMRESTRICT dest, const unsigned *BMRESTRICT block, unsigned dest_len) BMNOEXCEPT
Convert bit block to GAP representation.
const unsigned set_sub_array_size
void compute_s_block_descr(const bm::word_t *BMRESTRICT block, block_waves_xor_descr &BMRESTRICT x_descr, unsigned *BMRESTRICT s_gc, unsigned *BMRESTRICT s_bc) BMNOEXCEPT
Compute reference (non-XOR) 64-dim complexity descriptor for the s-block.
const unsigned sblock_flag_sb32
32-bit SB index
const unsigned char set_block_16one
UP to 65536 all-set blocks.
void for_each_dgap(const T *gap_buf, Func &func)
BMFORCEINLINE void get_block_coord(BI_TYPE nb, unsigned &i, unsigned &j) BMNOEXCEPT
Recalc linear bvector block index into 2D matrix coordinates.
void combine_count_operation_with_block(const bm::word_t *blk, const bm::word_t *arg_blk, distance_metric_descriptor *dmit, distance_metric_descriptor *dmit_end) BMNOEXCEPT
Internal function computes different distance metrics.
const unsigned sblock_flag_max32
const unsigned sblock_flag_min32
const unsigned set_total_blocks
const unsigned char set_nb_sync_mark48
const unsigned char set_block_arrgap_bienc
Interpolated GAP array.
ByteOrder
Byte orders recognized by the library.
const unsigned char set_block_8one
Up to 256 all-set blocks.
const unsigned char set_nb_sync_mark16
const unsigned char set_block_32one
UP to 4G all-set blocks.
const unsigned char set_block_bit_0runs
Bit block with encoded zero intervals.
const unsigned char set_block_xor_ref8_um
block is un-masked XOR of a reference block (8-bit)
const unsigned char set_block_64one
lots of all-set blocks
const unsigned char set_block_gap_bienc
Interpolated GAP block (legacy)
const unsigned char set_block_xor_gap_ref16
..... 16-bit
const unsigned set_compression_default
Default compression level.
const unsigned char set_block_arrbit
List of bits ON.
const unsigned char set_block_1one
One block all-set (1111...)
const unsigned char set_block_arrgap_inv
List of bits OFF (GAP block)
void convert_sub_to_arr(const BV &bv, unsigned sb, VECT &vect)
convert sub-blocks to an array of set 1s (32-bit)
const unsigned gap_levels
const unsigned char set_block_gapbit
GAP compressed bitblock.
void bit_recomb(It1 &it1, It2 &it2, BinaryOp &op, Encoder &enc, unsigned block_size=bm::set_block_size) BMNOEXCEPT
const unsigned char set_block_arr_bienc_8bh
BIC block 8bit header.
bm::operation setop2op(bm::set_operation op) BMNOEXCEPT
Convert set operation to operation.
const unsigned char set_sblock_bienc
super-block interpolated list
const unsigned char set_block_xor_chain
XOR chain (composit of sub-blocks)
const unsigned char set_nb_bookmark32
jump ahead mark (32-bit)
const unsigned sblock_flag_max24
const unsigned set_sub_total_bits
const unsigned set_block_size
unsigned long long int id64_t
const unsigned block_waves
const unsigned char set_block_xor_ref16
block is masked XOR of a reference block (16-bit)
const unsigned char set_block_arrgap_bienc_inv
Interpolated GAP array (inverted)
const unsigned char set_block_arrgap_egamma
Gamma compressed delta GAP array.
const unsigned gap_equiv_len
const unsigned char set_block_1zero
One all-zero block.
const unsigned sblock_flag_min24
24-bit minv
const unsigned char set_block_end
End of serialization.
const unsigned gap_max_buff_len
const unsigned char set_block_arrgap_bienc_v2
//!< Interpolated GAP array (v2)
const unsigned char set_block_xor_gap_ref32
..... 32-bit (should never happen)
const unsigned char set_block_arrgap
List of bits ON (GAP block)
bit_representation
Possible representations for bit sets.
@ e_bit_bit
uncompressed bit-block
@ e_bit_IINT
Inverted int list.
@ e_bit_0
all 0s (empty block)
const unsigned char set_nb_sync_mark64
..... 64-bit (should never happen)
const unsigned char set_nb_sync_mark32
const unsigned char set_block_sgapgap
SGAP compressed GAP block.
const unsigned sparse_max_l5
serialization_header_mask
@ BM_HM_NO_GAPL
no GAP levels
@ BM_HM_ID_LIST
id list stored
@ BM_HM_NO_BO
no byte-order
@ BM_HM_SPARSE
very sparse vector
@ BM_HM_64_BIT
64-bit vector
@ BM_HM_RESIZE
resized vector
@ BM_HM_HXOR
horizontal XOR compression turned ON
BMFORCEINLINE unsigned long long bmi_bslr_u64(unsigned long long w) BMNOEXCEPT
const unsigned char set_block_arr_bienc
Interpolated block as int array.
const unsigned char set_block_64zero
lots of zero blocks
const unsigned char set_block_gap_bienc_v2
Interpolated GAP block (v2)
const unsigned char set_block_xor_ref8
block is masked XOR of a reference block (8-bit)
const unsigned char set_block_gap_egamma
Gamma compressed GAP block.
unsigned short gap_word_t
const unsigned char set_block_32zero
Up to 4G zero blocks.
const unsigned char set_block_8zero
Up to 256 zero blocks.
const unsigned char set_block_xor_ref16_um
block is un-masked XOR of a reference block (16-bit)
const unsigned gap_max_bits
const unsigned char set_block_bit_1bit
Bit block with 1 bit ON.
const unsigned char set_block_aone
All other blocks one.
const unsigned char set_nb_bookmark16
jump ahead mark (16-bit)
const unsigned set_block_shift
const unsigned sblock_flag_len16
16-bit len (8-bit by default)
const unsigned set_compression_max
Maximum supported compression level.
BMFORCEINLINE unsigned long long bmi_blsi_u64(unsigned long long w)
const unsigned char set_nb_sync_mark24
const unsigned char set_block_xor_gap_ref8
..... 8-bit
const unsigned sparse_max_l6
const unsigned char set_block_azero
All other blocks zero.
const unsigned bits_in_block
const unsigned char set_block_16zero
Up to 65536 zero blocks.
const unsigned char set_block_bit
Plain bit block.
const unsigned char set_block_bitgap_bienc_v2
Interpolated bit-block as GAPs (v2 - reseved)
const unsigned char set_nb_bookmark24
jump ahead mark (24-bit)
const unsigned sblock_flag_min16
16-bit minv
bool is_const_set_operation(set_operation op) BMNOEXCEPT
Returns true if set operation is constant (bitcount)
const unsigned char set_block_sgapbit
SGAP compressed bitblock.
Bit COUNT SUB AB functor.
bm::xor_complement_match match
Structure to compute XOR gap-count profile by sub-block waves.
unsigned short sb_bc[bm::block_waves]
BIT counts.
unsigned short sb_gc[bm::block_waves]
GAP counts.
size_t max_serialize_mem
estimated maximum memory for serialization
Statistical information about bitset's memory allocation details.
static ByteOrder byte_order()
Bookmark state structure.
unsigned bm_type_
0:32-bit, 1: 24-bit, 2: 16-bit
bookmark_state(block_idx_type nb_range) BMNOEXCEPT
size_t min_bytes_range_
minumal distance (bytes) between marks
block_idx_type nb_
bookmark block idx
unsigned char * ptr_
bookmark pointer
block_idx_type nb_range_
target bookmark range in blocks
Parameters for XOR similarity search.