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,
707template<class BV, class SerialIterator>
726 bool exit_on_one =
false);
729 typedef typename BV::blocks_manager_type blocks_manager_type;
741 size_type finalize_target_vector(blocks_manager_type& bman,
752 {
return "BM::de-serialization format error"; }
766template<
class DEC,
typename BLOCK_IDX>
949 const unsigned char* buf,
951 bool exit_on_one =
false);
961 const unsigned char* buf,
983 const unsigned char* buf,
986 bool exit_on_one =
false)
997 const unsigned char* buf,
1010 { ref_vect_ = ref_vect; }
1014 const unsigned char* buf,
1023 const unsigned char* buf,
1030 typename BV::blocks_manager_type blocks_manager_type;
1043 allocator_type alloc_;
1054 deserializer_le de_le_;
1055 deserializer_be de_be_;
1170 compression_stat_(0),
1172 byte_order_serial_(true),
1173 sb_bookmarks_(false),
1176 enc_header_pos_(0), header_flag_(0),
1184 if (temp_block == 0)
1186 temp_block_ = alloc_.alloc_bit_block();
1187 own_temp_block_ =
true;
1191 temp_block_ = temp_block;
1192 own_temp_block_ =
false;
1194 compression_stat_ = (
size_type*) alloc_.alloc_bit_block();
1195 optimize_ = free_ =
false;
1196 xor_tmp1_ = xor_tmp2_ = 0;
1202 compression_stat_(0),
1204 byte_order_serial_(true),
1205 sb_bookmarks_(false),
1208 enc_header_pos_(0), header_flag_(0),
1216 if (temp_block == 0)
1218 temp_block_ = alloc_.alloc_bit_block();
1219 own_temp_block_ =
true;
1223 temp_block_ = temp_block;
1224 own_temp_block_ =
false;
1226 compression_stat_ = (
size_type*) alloc_.alloc_bit_block();
1227 optimize_ = free_ =
false;
1228 xor_tmp1_ = xor_tmp2_ = 0;
1234 if (own_temp_block_)
1235 alloc_.free_bit_block(temp_block_);
1236 if (compression_stat_)
1237 alloc_.free_bit_block((
bm::word_t*)compression_stat_);
1239 alloc_.free_bit_block(xor_tmp_block_, 3);
1246 for (
unsigned i = 0; i < 256; ++i)
1247 compression_stat_[i] = 0;
1254 compression_level_ = clevel;
1255 if (compression_level_ == 5)
1257 else if (compression_level_ == 6)
1266 sparse_cutoff_ = cutoff;
1274 gap_serial_ = value;
1280 byte_order_serial_ = value;
1286 sb_bookmarks_ = enable;
1289 if (bm_interval > 512)
1292 if (bm_interval < 4)
1295 sb_range_ = bm_interval;
1301 ref_vect_ = ref_vect;
1303 xor_scan_.set_ref_vector(ref_vect);
1304 if (!xor_tmp_block_ && ref_vect)
1306 xor_tmp_block_ = alloc_.alloc_bit_block(3);
1317 return xor_scan_.compute_sim_model(sim_model, ref_vect, params);
1323 sim_model_ = sim_model;
1343 if (!byte_order_serial_)
1359 enc_header_pos_ = enc.get_pos();
1360 enc.put_8(header_flag_);
1362 if (byte_order_serial_)
1365 enc.put_8((
unsigned char)bo);
1377 enc.put_64(bv.size());
1379 enc.put_32(bv.size());
1402 if (tail_delta < 256)
1408 enc.put_8((
unsigned char)min_v);
1412 if (tail_delta < 256)
1413 enc.put_8((
unsigned char)tail_delta);
1415 enc.put_16(tail_delta);
1417 bit_out_type bout(enc);
1424 unsigned gamma_size = (unsigned)(enc_pos1 - enc_pos0);
1427 enc.set_pos(enc_pos0);
1438 enc.put_16(gap_block, len-1);
1449 if (len > 3 && (compression_level_ > 3))
1453 bit_out_type bout(enc);
1454 gamma_encoder_func gamma(bout);
1457 enc.put_16(gap_block[0]);
1464 unsigned gamma_size = (unsigned)(enc_pos1 - enc_pos0);
1467 enc.set_pos(enc_pos0);
1478 enc.put_16(gap_block, len-1);
1491 if (compression_level_ > 3 && arr_len > 1)
1495 bit_out_type bout(enc);
1497 bout.
gamma(arr_len);
1499 bout.
gamma(prev + 1);
1501 for (
unsigned i = 1; i < arr_len; ++i)
1504 bout.
gamma(curr - prev);
1509 unsigned gamma_size = (unsigned)(enc_pos1 - enc_pos0);
1511 if (gamma_size >= plain_size)
1513 enc.set_pos(enc_pos0);
1517 compression_stat_[scode]++;
1523 enc.put_prefixed_array_16(scode, gap_array, arr_len,
true);
1524 compression_stat_[scode]++;
1542 bit_out_type bout(enc);
1552 bout.
gamma(arr_len-4);
1557 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
1559 if (enc_size >= raw_size)
1561 enc.set_pos(enc_pos0);
1565 compression_stat_[scode]++;
1571 enc.put_prefixed_array_16(scode, gap_block, arr_len,
true);
1572 compression_stat_[scode]++;
1592 if (min_v >= 256 && tail >= 256)
1601 bit_out_type bout(enc);
1612 arr_len |= (1 << 1);
1616 enc.put_8((
unsigned char)min_v);
1621 enc.put_8((
unsigned char)tail);
1631 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
1633 if (enc_size >= raw_size)
1635 enc.set_pos(enc_pos0);
1639 compression_stat_[scode]++;
1645 enc.put_prefixed_array_16(scode, gap_block, arr_len,
true);
1646 compression_stat_[scode]++;
1655 scores_[mod_size_] = score; models_[mod_size_] = mod;
1663 const float bie_bits_per_int = compression_level_ < 6 ? 3.75f : 2.5f;
1664 const unsigned bie_limit = unsigned(
float(
bm::gap_max_bits) / bie_bits_per_int);
1666 unsigned bc, ibc, gc;
1678 bit_model_d0_size_ = unsigned(8 + (32 * d0_bc *
sizeof(
bm::word_t)));
1691 unsigned arr_size_inv =
1698 float gcf=float(gc);
1702 32 +
unsigned((gcf-1) * bie_bits_per_int));
1705 float bcf=float(bc), ibcf=float(ibc);
1711 if (ibc < bie_limit)
1713 16 * 3 +
unsigned(ibcf * bie_bits_per_int));
1716 gc -= gc > 2 ? 2 : 0;
1721 16 * 4 +
unsigned(gcf * bie_bits_per_int));
1727 16 * 4 +
unsigned(gcf * bie_bits_per_int));
1734 for (
unsigned i = 0; i < mod_size_; ++i)
1736 if (scores_[i] < min_score)
1738 min_score = scores_[i];
1745 std::cout <<
" 0runs=" << (bit_model_0run_size_ * 8) << std::endl;
1746 std::cout <<
" GAP BIC=" << (16 * 4 + unsigned(gcf * bie_bits_per_int)) << std::endl;
1747 std::cout <<
" ARR BIC=" << (16 * 3 + unsigned(bcf * bie_bits_per_int)) << std::endl;
1748 std::cout <<
"BC,GC=[" << bc <<
", " << gc <<
"]" << std::endl;
1749 std::cout <<
"bie_limit=" << bie_limit << std::endl;
1754 case set_block_bit: std::cout <<
"BIT=" <<
"[" << bc <<
", " << gc <<
"]";
break;
1766 case set_block_bit_0runs: std::cout <<
"0runs=[" << bc <<
", " << gc <<
" lmt=" << bie_limit <<
"]";
break;
1769 default: std::cout <<
"UNK=" << int(model);
break;
1782 const float bie_bits_per_int = compression_level_ < 6 ? 3.75f : 2.5f;
1784 unsigned wave_matches[
e_bit_end] = {0, };
1787 unsigned s_gc, s_bc;
1793 s_gc = x_descr.
sb_gc[i];
1794 s_bc = x_descr.
sb_bc[i];
1798 wave_matches[best_rep]++;
1800 unsigned sum_cases = 0;
1801 bool sub_diff =
false;
1802 unsigned v_count = 0;
1803 for (
unsigned i = 0; i <
e_bit_end; ++i)
1805 sum_cases += wave_matches[i];
1806 if (wave_matches[i] != 0 && wave_matches[i] < 64)
1808 sub_diff =
true; v_count++;
1813 std::cout <<
"-" << v_count;
1818 if (wave_matches[i])
1822 case e_bit_GAP: std::cout <<
" G" << wave_matches[i];
break;
1823 case e_bit_INT: std::cout <<
" I" << wave_matches[i];
break;
1824 case e_bit_IINT: std::cout <<
"iI" << wave_matches[i];
break;
1825 case e_bit_1: std::cout <<
" 1s" << wave_matches[i];
break;
1826 case e_bit_0: std::cout <<
" 0s" << wave_matches[i];
break;
1827 case e_bit_bit: std::cout <<
" B" << wave_matches[i];
break;
1843 if (compression_level_ >= 5)
1846 unsigned bc, bit_gaps;
1853 if (compression_level_ <= 1)
1858 if (compression_level_ <= 5)
1861 if (compression_level_ >= 2)
1870 bit_model_d0_size_ = unsigned(8 + (32 * d0_bc *
sizeof(
bm::word_t)));
1874 if (compression_level_ >= 4)
1897 if (compression_level_ >= 3)
1901 unsigned arr_size_inv =
1907 if (compression_level_ >= 4)
1909 const unsigned gamma_bits_per_int = 6;
1912 if (compression_level_ == 4)
1916 16 + (bit_gaps-1) * gamma_bits_per_int);
1919 16 + bc * gamma_bits_per_int);
1920 if (inverted_bc > 3 && inverted_bc < bit_gaps && inverted_bc <
bm::gap_equiv_len)
1922 16 + inverted_bc * gamma_bits_per_int);
1932 for (
unsigned i = 0; i < mod_size_; ++i)
1934 if (scores_[i] < min_score)
1936 min_score = scores_[i];
1950 if (compression_level_ <= 2)
1966 if (compression_level_ < 4 || len < 6)
1969 if (compression_level_ == 4)
1976 if (compression_level_ < 4 || len < 6)
1979 if (compression_level_ == 4)
1986 if (compression_level_ == 4)
2001 bool invert =
false;
2016 enc.
put_16(gap_temp_block[0]);
2062 enc.put_8((blk[0]==0) ? 0 : 1);
2098 enc.put_32(blk + i, j - i);
2116 if (bit_model_0run_size_ < bit_model_d0_size_)
2135 enc.put_32(block[off+j+0]);
2136 enc.put_32(block[off+j+1]);
2137 enc.put_32(block[off+j+2]);
2138 enc.put_32(block[off+j+3]);
2170 enc.put_8(vbr_flag);
2174 ridx = ref_vect_->get_row_idx(ridx);
2178 case 1: enc.put_8((
unsigned char)ridx);
break;
2179 case 2: enc.put_16((
unsigned short)ridx);
break;
2180 case 0: enc.put_32((
unsigned)ridx);
break;
2184 enc.put_8((
unsigned char) (chain_size-1));
2186 for (
unsigned ci = 1; ci < chain_size; ++ci)
2188 ridx = mchain.ref_idx[ci];
2189 d64 = mchain.xor_d64[ci];
2190 ridx = ref_vect_->get_row_idx(ridx);
2193 case 1: enc.put_8((
unsigned char)ridx);
break;
2194 case 2: enc.put_16((
unsigned short)ridx);
break;
2195 case 0: enc.put_32((
unsigned)ridx);
break;
2214 s_block = xor_tmp1_;
2217 const bm::word_t* ref_block = xor_scan_.get_ref_block(ridx, i, j);
2221 ref_block = xor_tmp2_;
2225 for (
unsigned k = 1; k < mchain.chain_size; ++k)
2227 ridx = mchain.ref_idx[k];
2228 ref_block = xor_scan_.get_ref_block(ridx, i, j);
2232 ref_block = xor_tmp2_;
2234 d64 = mchain.xor_d64[k];
2248 bv.calc_stat(&stat);
2253 optimize_ = free_ =
false;
2255 unsigned char* data_buf = buf.data();
2256 size_t buf_size = buf.size();
2274 mp_g_z.assign_if_not_set(pool_, bv);
2276 bv.optimize(temp_block_, BV::opt_compress, &st);
2279 optimize_ = free_ =
false;
2292 unsigned char scode =
2294 enc.put_prefixed_array_16(scode, bit_idx_arr_.data(), arr_len,
true);
2295 compression_stat_[scode]++;
2362 bit_out_type bout(enc);
2372 enc.put_8((
unsigned char)head);
2379 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
2381 if (enc_size >= raw_size)
2383 enc.set_pos(enc_pos0);
2387 compression_stat_[scode]++;
2414 unsigned sb_flag = 0;
2418 unsigned len = (unsigned)sb_bit_idx_arr_.size();
2420 BM_ASSERT(sb_bit_idx_arr_.size() < 65536);
2438 if (min_v < 0xFFFFFF)
2442 else if (min_v > 255)
2445 if (max_v_delta > 65535)
2446 if (max_v_delta < 0xFFFFFF)
2450 else if (max_v_delta > 255)
2456 enc.put_8((
unsigned char)sb_flag);
2461 enc.put_16((
unsigned short)sb);
2463 enc.put_8((
unsigned char)sb);
2466 enc.put_16((
unsigned short)len);
2468 enc.put_8((
unsigned char)len);
2471 if (min_v < 0xFFFFFF)
2475 else if (min_v > 255)
2476 enc.put_16((
unsigned short)min_v);
2478 enc.put_8((
unsigned char)min_v);
2480 if (max_v_delta > 65535)
2481 if (max_v < 0xFFFFFF)
2482 enc.put_24(max_v_delta);
2484 enc.put_32(max_v_delta);
2485 else if (max_v_delta > 255)
2486 enc.put_16((
unsigned short)max_v_delta);
2488 enc.put_8((
unsigned char)max_v_delta);
2490 bit_out_type bout(enc);
2492 (
unsigned)sb_bit_idx_arr_.size()-2,
2495 compression_stat_[scode]++;
2507 bit_idx_arr_.data(), block, inverted);
2511 unsigned char scode =
2516 bit_out_type bout(enc);
2523 if (!inverted && min_v <= 0xFF && max_delta <= 0xFF)
2526 enc.put_8((
unsigned char)min_v);
2527 enc.put_8((
unsigned char)max_delta);
2541 unsigned enc_size = (unsigned)(enc_pos1 - enc_pos0);
2543 if (enc_size >= raw_size)
2545 enc.set_pos(enc_pos0);
2549 if (digest0_ != ~0ull && enc_size > bit_model_d0_size_)
2551 enc.set_pos(enc_pos0);
2555 compression_stat_[scode]++;
2567#define BM_SER_NEXT_GRP(enc, nb, B_1ZERO, B_8ZERO, B_16ZERO, B_32ZERO, B_64ZERO) \
2569 enc.put_8(B_1ZERO); \
2570 else if (nb < 256u) \
2572 enc.put_8(B_8ZERO); \
2573 enc.put_8((unsigned char)nb); \
2575 else if (nb < 65536u) \
2577 enc.put_8(B_16ZERO); \
2578 enc.put_16((unsigned short)nb); \
2580 else if (nb < bm::id_max32) \
2582 enc.put_8(B_32ZERO); \
2583 enc.put_32(unsigned(nb)); \
2587 enc.put_8(B_64ZERO); \
2600 if (bookm.ptr_ && nb_delta >= bookm.nb_range_)
2602 unsigned char* curr = enc.get_pos();
2603 size_t bytes_delta = size_t(curr - bookm.ptr_);
2604 if (bytes_delta > bookm.min_bytes_range_)
2606 enc.set_pos(bookm.ptr_);
2607 switch (bookm.bm_type_)
2610 bytes_delta -=
sizeof(unsigned);
2611 if (bytes_delta < 0xFFFFFFFF)
2612 enc.put_32(
unsigned(bytes_delta));
2616 bytes_delta -= (
sizeof(unsigned)-1);
2617 if (bytes_delta < 0xFFFFFF)
2618 enc.put_24(
unsigned(bytes_delta));
2621 bytes_delta -=
sizeof(
unsigned short);
2622 if (bytes_delta < 0xFFFF)
2623 enc.put_16((
unsigned short)bytes_delta);
2632 if (nb_delta < 0xFF)
2635 enc.put_8((
unsigned char) nb_delta);
2638 if (nb_delta < 0xFFFF)
2641 enc.put_16((
unsigned short) nb_delta);
2644 if (nb_delta < 0xFFFFFF)
2647 enc.put_24(
unsigned(nb_delta));
2653 enc.put_32(
unsigned(nb_delta));
2658 if (nb_delta < 0xFFFFFFFFFFFFUL)
2661 enc.put_48(nb_delta);
2666 enc.put_64(nb_delta);
2678 bookm.ptr_ = enc.get_pos() + 1;
2679 switch (bookm.bm_type_)
2704 unsigned char* buf,
size_t buf_size)
2708 if (allow_stat_reset_)
2713 enc_header_pos_ = 0;
2718 unsigned i_last = ~0u;
2726 if (i0 < bman.top_block_size())
2740 if ((compression_level_ >= 5) && (i0 != i_last))
2743 bool is_sparse_sub = bman.is_sparse_sblock(i0, sparse_cutoff_);
2758 const bm::word_t* blk = bman.get_block(i0, j0);
2779 enc.
put_8(header_flag_);
2784 if (nb > 1 && nb < 128)
2787 unsigned char c = (
unsigned char)((1u << 7) | nb);
2814 bm::word_t*** blk_root = bman.top_blocks_root();
2821 const bm::word_t* blk_next = bman.get_block(i0, j0);
2853 bool nb_indexed = sim_model_->bv_blocks.test(i);
2858 size_type rank = sim_model_->bv_blocks.count_range(0, i);
2862 sim_model_->matr.get(ref_idx_, rank);
2864 switch (mchain.
match)
2872 size_type plain_idx = ref_vect_->get_row_idx(ridx);
2874 enc.
put_32(
unsigned(plain_idx));
2890 size_type plain_idx = ref_vect_->get_row_idx(ridx);
2912 blk = xor_tmp_block_;
2942 unsigned bit_idx = 0;
3014 enc.
put_8(header_flag_);
3086 return (
size_t) bv_serial.
serialize(bv, buf, 0);
3138 const unsigned char* buf,
3145 unsigned char header_flag = dec.
get_8();
3152 if (bo_current == bo)
3201 const unsigned char* buf,
3202 typename BV::size_type from,
3203 typename BV::size_type to,
3209 unsigned char header_flag = dec.
get_8();
3216 if (bo_current == bo)
3247 bv.keep_range(from, to);
3251template<
typename DEC,
typename BLOCK_IDX>
3254 unsigned block_type,
3279 if (k == 0) --bit_idx;
3282 dst_arr[k] = bit_idx;
3295 dst_arr[len-1] = max_v;
3319 dst_arr[len-1] = max_v;
3327 throw std::logic_error(
err_msg());
3329 BM_THROW(BM_ERR_SERIALFORMAT);
3335template<
typename DEC,
typename BLOCK_IDX>
3347 min_v = dec.get_16();
3348 max_v = dec.get_16();
3351 min_v = dec.get_8();
3352 max_delta = dec.get_8();
3360 arr_len = dec.get_16();
3374template<
typename DEC,
typename BLOCK_IDX>
3377 unsigned block_type,
3381 unsigned len(0), sb_flag(0);
3389 sb_flag = dec.get_8();
3392 *sb_idx = dec.get_32();
3394 *sb_idx = dec.get_16();
3396 *sb_idx = dec.get_8();
3406 min_v = dec.get_32();
3408 min_v = dec.get_24();
3410 min_v = dec.get_16();
3412 min_v = dec.get_8();
3417 max_v = dec.get_32();
3419 max_v = dec.get_24();
3421 max_v = dec.get_16();
3423 max_v = dec.get_8();
3427 dst_arr[len-1] = max_v;
3434 throw std::logic_error(
err_msg());
3436 BM_THROW(BM_ERR_SERIALFORMAT);
3443template<
typename DEC,
typename BLOCK_IDX>
3454template<
typename DEC,
typename BLOCK_IDX>
3461 unsigned arr_len = dec.get_16();
3477template<
typename DEC,
typename BLOCK_IDX>
3505 block[off+j+0] |= dec.get_32();
3506 block[off+j+1] |= dec.get_32();
3507 block[off+j+2] |= dec.get_32();
3508 block[off+j+3] |= dec.get_32();
3517template<
typename DEC,
typename BLOCK_IDX>
3525 unsigned char run_type = dec.get_8();
3528 unsigned run_length = dec.get_16();
3531 unsigned run_end = j + run_length;
3533 for (;j < run_end; ++j)
3535 unsigned w = dec.get_32();
3547template<
typename DEC,
typename BLOCK_IDX>
3550 unsigned block_type,
3561 *dst_block = gap_head;
3602 unsigned len = (gap_head >> 3);
3605 *dst_block = gap_head;
3611 for (
unsigned i = 1; i < len; ++i)
3615 *(++gap_data_ptr) = gap_sum;
3622 unsigned len = (gap_head >> 3);
3623 *dst_block = gap_head;
3625 dst_block[1] = min_v;
3634 unsigned len = (gap_head >> 3);
3648 dst_block[0] = gap_head;
3649 dst_block[1] = min_v;
3652 dst_block[len-1] = max_v;
3659 throw std::logic_error(
err_msg());
3661 BM_THROW(BM_ERR_SERIALFORMAT);
3674template<
typename DEC,
typename BLOCK_IDX>
3734 if (nb_sync <= expect_nb)
3748template<
class BV,
class DEC>
3769template<
class BV,
class DEC>
3778template<
class BV,
class DEC>
3786template<
class BV,
class DEC>
3796 bool inv_flag =
false;
3799 bman.reserve_top_blocks(i0+1);
3800 bman.check_alloc_top_subblock(i0);
3809 (
sizeof(
gap_word_t) == 2 ? dec.get_16() : dec.get_32());
3816 *gap_temp_block = gap_head;
3817 dec.get_16(gap_temp_block+1, len - 1);
3822 blk = bman.get_allocator().alloc_bit_block();
3823 bman.set_block(nb, blk);
3830 bv.combine_operation_block_or(i0, j0, blk,
temp_block_);
3841 bman.get_allocator().alloc_gap_block(
unsigned(level), bman.glen());
3843 *gap_blk_ptr = gap_head;
3849 dec.get_16(gap_blk + 1, len - 1);
3855 *gap_temp_block = gap_head;
3856 dec.get_16(gap_temp_block + 1, len - 1);
3874 gap_temp_block[0] = 0;
3885 bv.combine_operation_block_or(i0, j0, blk,
temp_block_);
3891 gap_head = dec.get_16();
3903 gap_head = dec.get_16();
3909 throw std::logic_error(this->
err_msg());
3911 BM_THROW(BM_ERR_SERIALFORMAT);
3919 blk = bman.get_allocator().alloc_bit_block();
3921 bman.set_block_ptr(i0, j0, blk);
3926 bv.combine_operation_block_or(i0, j0, blk,
temp_block_);
3933 bv.combine_operation_block_or(i0, j0, blk, tmp_blk);
3937template<
class BV,
class DEC>
3946 blk = bman.get_allocator().alloc_bit_block();
3947 bman.set_block(nb, blk);
3952 blk = bman.deoptimize_block(nb);
3960 blk = bman.deoptimize_block(nb);
3964 for (
unsigned k = 0; k < len; ++k)
3979 blk = bman.deoptimize_block(nb);
3995 throw std::logic_error(this->
err_msg());
3997 BM_THROW(BM_ERR_SERIALFORMAT);
4002template<
class BV,
class DEC>
4011 typename BV::size_type from = sb * sb_max_bc;
4015 for (
typename BV::size_type i = 0; i < len; ++i)
4017 typename BV::size_type idx = from + arr[i];
4022 bv.set_bit_no_check(idx);
4027 for (
typename BV::size_type i = 0; i < len; ++i)
4029 typename BV::size_type idx = from + arr[i];
4030 bv.set_bit_no_check(idx);
4036template<
class BV,
class DEC>
4045 blk = bman.get_allocator().alloc_bit_block();
4046 bman.set_block(nb, blk);
4056template<
class BV,
class DEC>
4062 unsigned head_idx = dec.get_16();
4063 unsigned tail_idx = dec.get_16();
4067 blk = bman.get_allocator().alloc_bit_block();
4068 bman.set_block(nb, blk);
4069 for (
unsigned k = 0; k < head_idx; ++k)
4071 dec.get_32(blk + head_idx, tail_idx - head_idx + 1);
4078 dec.get_32(
temp_block_ + head_idx, tail_idx - head_idx + 1);
4083template<
class BV,
class DEC>
4093 blk = bman.deoptimize_block(nb);
4099 blk = bman.get_allocator().alloc_bit_block();
4101 bman.set_block(nb, blk);
4106 for (
unsigned k = 0; k < len; ++k)
4112 for (
unsigned k = 0; k < len; ++k)
4121template<
class BV,
class DEC>
4123 const unsigned char* buf,
4127 if (!bman.is_init())
4129 auto bc = bman.compute_top_block_size(
bm::id_max-1);
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())
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;
4345 bv.set_bit_no_check(bit_idx);
4352 bv.combine_operation_with_block(nb_i, temp_block, 0,
BM_OR);
4398 goto process_bookmark;
4402 goto process_bookmark;
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;
4439 throw std::logic_error(this->
err_msg());
4441 BM_THROW(BM_ERR_SERIALFORMAT);
4454 row_idx = dec.get_32();
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();
4506 or_block_ = bman.deoptimize_block(nb_i);
4507 bman.set_block_ptr(nb_i, 0);
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;
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;
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);
4583 bman.shrink_top_blocks();
4590template<
class BV,
class DEC>
4621template<
class BV,
class DEC>
4635 ref_blk = ref_bman.get_block_ptr(i0, j0);
4643 bm::word_t* blk = bman.deoptimize_block(i0, j0,
true);
4658 bm::word_t* blk = bman.deoptimize_block(i0, j0,
true);
4670 bm::word_t* blk = bman.get_block_ptr(i0, j0);
4683 bman.assign_gap_check(i0, j0, res, ++res_len, blk, tmp_buf);
4698 bm::word_t* blk = bman.deoptimize_block(i0, j0,
true);
4732 bman.optimize_bit_block_nocheck(i0, j0);
4737template<
class BV,
class DEC>
4746template<
typename DEC,
typename BLOCK_IDX>
4839 throw std::bad_alloc();
4841 BM_THROW(BM_ERR_BADALLOC);
4848template<
typename DEC,
typename BLOCK_IDX>
4856template<
typename DEC,
typename BLOCK_IDX>
5010 goto process_nb_sync;
5013 goto process_nb_sync;
5016 goto process_nb_sync;
5019 goto process_nb_sync;
5022 goto process_nb_sync;
5030 throw std::logic_error(this->
err_msg());
5032 BM_THROW(BM_ERR_SERIALFORMAT);
5059 throw std::logic_error(this->
err_msg());
5061 BM_THROW(BM_ERR_SERIALFORMAT);
5082 throw std::logic_error(this->
err_msg());
5084 BM_THROW(BM_ERR_SERIALFORMAT);
5089template<
typename DEC,
typename BLOCK_IDX>
5105template<
typename DEC,
typename BLOCK_IDX>
5113 for (
unsigned k = 0; k < len; ++k)
5121 for (
unsigned k = 0; k < len; ++k)
5127template<
typename DEC,
typename BLOCK_IDX>
5147 unsigned char run_type =
decoder_.get_8();
5150 unsigned run_length =
decoder_.get_16();
5153 decoder_.get_32(dst_block ? dst_block + j : dst_block, run_length);
5161 unsigned head_idx =
decoder_.get_16();
5162 unsigned tail_idx =
decoder_.get_16();
5165 for (
unsigned i = 0; i < head_idx; ++i)
5167 decoder_.get_32(dst_block + head_idx,
5168 tail_idx - head_idx + 1);
5174 int pos = int(tail_idx - head_idx) + 1;
5187 throw std::logic_error(this->
err_msg());
5189 BM_THROW(BM_ERR_SERIALFORMAT);
5219 throw std::logic_error(this->
err_msg());
5221 BM_THROW(BM_ERR_SERIALFORMAT);
5227template<
typename DEC,
typename BLOCK_IDX>
5242 unsigned head_idx =
decoder_.get_16();
5243 unsigned tail_idx =
decoder_.get_16();
5244 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5250 unsigned char run_type =
decoder_.get_8();
5253 unsigned run_length =
decoder_.get_16();
5256 unsigned run_end = j + run_length;
5257 for (;j < run_end; ++j)
5295 throw std::logic_error(this->
err_msg());
5297 BM_THROW(BM_ERR_SERIALFORMAT);
5303template<
typename DEC,
typename BLOCK_IDX>
5319 unsigned char run_type =
decoder_.get_8();
5322 unsigned run_length =
decoder_.get_16();
5324 unsigned run_end = j + run_length;
5327 for (;j < run_end; ++j)
5335 for (;j < run_end; ++j)
5346 unsigned head_idx =
decoder_.get_16();
5347 unsigned tail_idx =
decoder_.get_16();
5349 for ( i = 0; i < head_idx; ++i)
5351 for ( i = head_idx; i <= tail_idx; ++i)
5409 throw std::logic_error(this->
err_msg());
5411 BM_THROW(BM_ERR_SERIALFORMAT);
5417template<
typename DEC,
typename BLOCK_IDX>
5435 unsigned char run_type =
decoder_.get_8();
5438 unsigned run_length =
decoder_.get_16();
5441 unsigned run_end = j + run_length;
5442 for (;j < run_end; ++j)
5457 unsigned head_idx =
decoder_.get_16();
5458 unsigned tail_idx =
decoder_.get_16();
5459 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5515 throw std::logic_error(this->
err_msg());
5517 BM_THROW(BM_ERR_SERIALFORMAT);
5523template<
typename DEC,
typename BLOCK_IDX>
5537 dst_block[i] &= ~
decoder_.get_32();
5541 unsigned char run_type =
decoder_.get_8();
5544 unsigned run_length =
decoder_.get_16();
5547 unsigned run_end = j + run_length;
5548 for (;j < run_end; ++j)
5563 unsigned head_idx =
decoder_.get_16();
5564 unsigned tail_idx =
decoder_.get_16();
5565 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5566 dst_block[i] &= ~
decoder_.get_32();
5618 throw std::logic_error(this->
err_msg());
5620 BM_THROW(BM_ERR_SERIALFORMAT);
5627template<
typename DEC,
typename BLOCK_IDX>
5645 unsigned char run_type =
decoder_.get_8();
5648 unsigned run_length =
decoder_.get_16();
5651 unsigned run_end = j + run_length;
5652 for (;j < run_end; ++j)
5666 unsigned head_idx =
decoder_.get_16();
5667 unsigned tail_idx =
decoder_.get_16();
5668 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5703 throw std::logic_error(this->
err_msg());
5705 BM_THROW(BM_ERR_SERIALFORMAT);
5712template<
typename DEC,
typename BLOCK_IDX>
5733 unsigned char run_type =
decoder_.get_8();
5736 unsigned run_length =
decoder_.get_16();
5739 unsigned run_end = j + run_length;
5740 for (;j < run_end; ++j)
5755 unsigned head_idx =
decoder_.get_16();
5756 unsigned tail_idx =
decoder_.get_16();
5757 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5786 throw std::logic_error(this->
err_msg());
5788 BM_THROW(BM_ERR_SERIALFORMAT);
5796template<
typename DEC,
typename BLOCK_IDX>
5815 unsigned char run_type =
decoder_.get_8();
5818 unsigned run_length =
decoder_.get_16();
5821 unsigned run_end = j + run_length;
5822 for (;j < run_end; ++j)
5836 unsigned head_idx =
decoder_.get_16();
5837 unsigned tail_idx =
decoder_.get_16();
5838 for (
unsigned i = head_idx; i <= tail_idx; ++i)
5873 throw std::logic_error(this->
err_msg());
5875 BM_THROW(BM_ERR_SERIALFORMAT);
5882template<
typename DEC,
typename BLOCK_IDX>
5909 unsigned char run_type =
decoder_.get_8();
5912 unsigned run_length =
decoder_.get_16();
5913 unsigned run_end = j + run_length;
5916 for (;j < run_end; ++j)
5924 for (;j < run_end; ++j)
5935 unsigned head_idx =
decoder_.get_16();
5936 unsigned tail_idx =
decoder_.get_16();
5939 for (i = 0; i < head_idx; ++i)
5941 for (i = head_idx; i <= tail_idx; ++i)
5975 throw std::logic_error(this->
err_msg());
5977 BM_THROW(BM_ERR_SERIALFORMAT);
5981 return count_adapter.
sum();
5984template<
typename DEC,
typename BLOCK_IDX>
6011 unsigned char run_type =
decoder_.get_8();
6014 unsigned run_length =
decoder_.get_16();
6015 unsigned run_end = j + run_length;
6018 for (;j < run_end; ++j)
6026 for (;j < run_end; ++j)
6037 unsigned head_idx =
decoder_.get_16();
6038 unsigned tail_idx =
decoder_.get_16();
6041 for (i = 0; i < head_idx; ++i)
6043 for (i = head_idx; i <= tail_idx; ++i)
6078 throw std::logic_error(this->
err_msg());
6080 BM_THROW(BM_ERR_SERIALFORMAT);
6084 return count_adapter.
sum();
6087template<
typename DEC,
typename BLOCK_IDX>
6114 unsigned char run_type =
decoder_.get_8();
6117 unsigned run_length =
decoder_.get_16();
6118 unsigned run_end = j + run_length;
6121 for (;j < run_end; ++j)
6129 for (;j < run_end; ++j)
6140 unsigned head_idx =
decoder_.get_16();
6141 unsigned tail_idx =
decoder_.get_16();
6144 for (i = 0; i < head_idx; ++i)
6146 for (i = head_idx; i <= tail_idx; ++i)
6181 throw std::logic_error(this->
err_msg());
6183 BM_THROW(BM_ERR_SERIALFORMAT);
6187 return count_adapter.
sum();
6190template<
typename DEC,
typename BLOCK_IDX>
6217 unsigned char run_type =
decoder_.get_8();
6220 unsigned run_length =
decoder_.get_16();
6221 unsigned run_end = j + run_length;
6224 for (;j < run_end; ++j)
6239 unsigned head_idx =
decoder_.get_16();
6240 unsigned tail_idx =
decoder_.get_16();
6243 for (i = head_idx; i <= tail_idx; ++i)
6276 throw std::logic_error(this->
err_msg());
6278 BM_THROW(BM_ERR_SERIALFORMAT);
6281 return count_adapter.
sum();
6286template<
typename DEC,
typename BLOCK_IDX>
6307 for (
unsigned k = 0; k < len; ++k)
6324template<
typename DEC,
typename BLOCK_IDX>
6334template<
typename DEC,
typename BLOCK_IDX>
6352template<
typename DEC,
typename BLOCK_IDX>
6363 unsigned cnt = ((*this).*(bit_func))(dst_block, tmp_block);
6376: temp_block_(0), ref_vect_(0)
6378 temp_block_ = alloc_.alloc_bit_block();
6386 alloc_.free_bit_block(temp_block_);
6398 typename BV::size_type count = 0;
6402 bv.bit_and(bv_tmp, BV::opt_compress);
6417 count = bv_tmp.count();
6443 BM_THROW(BM_ERR_SERIALFORMAT);
6453operation_deserializer<BV>::deserialize_xor(
bvector_type& bv,
6454 const unsigned char* buf,
6465 return deserialize_xor(bv, bv_tmp, op);
6469void operation_deserializer<BV>::deserialize_xor_range(
6471 const unsigned char* buf,
6479 bm::decoder dec(buf);
6480 unsigned char header_flag = dec.get_8();
6487 if (bo_current == bo)
6489 de_.set_ref_vectors(ref_vect_);
6490 de_.set_range(idx_from, idx_to);
6491 de_.deserialize(bv, buf);
6502 deserial.set_range(idx_from, idx_to);
6503 deserial.deserialize(bv, buf);
6510 deserial.set_range(idx_from, idx_to);
6511 deserial.deserialize(bv, buf);
6518 bv.keep_range_no_check(idx_from, idx_to);
6525operation_deserializer<BV>::deserialize_xor(
bvector_type& bv,
6545 count = bv_tmp.
count();
6568 throw std::logic_error(
"BM: serialization error");
6570 BM_THROW(BM_ERR_SERIALFORMAT);
6582 const unsigned char* buf,
6588 unsigned char header_flag = dec.
get_8();
6593 return deserialize_xor(bv, buf, op, exit_on_one);
6609 if (bo_current == bo)
6614 de_.deserialize(bv, buf);
6618 bv_tmp_.clear(
true);
6621 de_.deserialize(bv_tmp_, buf);
6633 if (bo_current == bo)
6635 serial_stream_current ss(buf);
6636 return it_d_.deserialize(bv, ss, temp_block_, op, exit_on_one);
6642 serial_stream_be ss(buf);
6643 return it_d_be_.deserialize(bv, ss, temp_block_, op, exit_on_one);
6647 serial_stream_le ss(buf);
6648 return it_d_le_.deserialize(bv, ss, temp_block_, op, exit_on_one);
6653 throw std::logic_error(
"BM::platform error: unknown endianness");
6655 BM_THROW(BM_ERR_SERIALFORMAT);
6663 const unsigned char* buf,
6669 unsigned char header_flag = dec.
get_8();
6676 blocks_manager_type& bman = bv.get_blocks_manager();
6677 if (!bman.is_init())
6678 bv.set_range(idx_from, idx_to);
6687 deserialize_xor_range(bv_tmp, buf, idx_from, idx_to);
6701 if (bo_current == bo)
6703 bv_tmp_.clear(
true);
6706 de_.set_range(idx_from, idx_to);
6707 de_.deserialize(bv_tmp_, buf);
6730 if (bo_current == bo)
6732 serial_stream_current ss(buf);
6733 it_d_.set_range(idx_from, idx_to);
6734 it_d_.deserialize(bv, ss, temp_block_, op,
false);
6735 it_d_.unset_range();
6742 serial_stream_be ss(buf);
6743 it_d_be_.set_range(idx_from, idx_to);
6744 it_d_be_.deserialize(bv, ss, temp_block_, op,
false);
6745 it_d_be_.unset_range();
6750 serial_stream_le ss(buf);
6751 it_d_le_.set_range(idx_from, idx_to);
6752 it_d_le_.deserialize(bv, ss, temp_block_, op,
false);
6753 it_d_le_.unset_range();
6759 throw std::logic_error(
"BM::platform error: unknown endianness");
6761 BM_THROW(BM_ERR_SERIALFORMAT);
6771template<
class BV,
class SerialIterator>
6775 is_range_set_ =
true;
6781template<
class BV,
class SerialIterator>
6782void iterator_deserializer<BV, SerialIterator>::load_id_list(
6784 serial_iterator_type& sit,
6788 const unsigned win_size = 64;
6793 for (
unsigned i = 0; i <= id_count;)
6796 for (j = 0; j < win_size && i <= id_count; ++j, ++i)
6798 id_buffer[j] = sit.get_id();
6806 for (
unsigned i = 0; i <= id_count;)
6809 for (j = 0; j < win_size && i <= id_count; ++j, ++i)
6811 id_buffer[j] = sit.get_id();
6819template<
class BV,
class SerialIterator>
6821iterator_deserializer<BV, SerialIterator>::finalize_target_vector(
6822 blocks_manager_type& bman,
6837 if (bv_block_idx <= nblock_last)
6838 bman.set_all_zero(bv_block_idx, nblock_last);
6847 bm::word_t*** blk_root = bman.top_blocks_root();
6848 unsigned top_size = bman.top_block_size();
6849 for (;i < top_size; ++i)
6862 count += bman.block_bitcount(blk_blk[j]);
6872 throw std::logic_error(err_msg());
6874 BM_THROW(BM_ERR_SERIALFORMAT);
6880template<
class BV,
class SerialIterator>
6882iterator_deserializer<BV, SerialIterator>::process_id_list(
6884 serial_iterator_type& sit,
6888 unsigned id_count = sit.get_id_count();
6889 bool set_clear =
true;
6896 load_id_list(bv_tmp, sit, id_count,
true);
6909 load_id_list(bv, sit, id_count, set_clear);
6912 for (
unsigned i = 0; i < id_count; ++i)
6920 for (
unsigned i = 0; i < id_count; ++i)
6930 for (
size_type i = 0; i < id_count; ++i)
6941 load_id_list(bv_tmp, sit, id_count,
true);
6949 load_id_list(bv_tmp, sit, id_count,
true);
6957 load_id_list(bv_tmp, sit, id_count,
false);
6958 count += bv_tmp.
count();
6964 load_id_list(bv_tmp, sit, id_count,
true);
6972 throw std::logic_error(err_msg());
6974 BM_THROW(BM_ERR_SERIALFORMAT);
6982template<
class BV,
class SerialIterator>
6995 gap_temp_block[0] = 0;
6997 blocks_manager_type& bman = bv.get_blocks_manager();
6998 if (!bman.is_init())
7001 if (sit.bv_size() && (sit.bv_size() > bv.size()))
7002 bv.resize(sit.bv_size());
7004 typename serial_iterator_type::iterator_state state;
7005 state = sit.get_state();
7006 if (state == serial_iterator_type::e_list_ids)
7008 count = process_id_list(bv, sit, op);
7020 count += finalize_target_vector(bman, op, bv_block_idx);
7024 state = sit.state();
7027 case serial_iterator_type::e_blocks:
7032 if (is_range_set_ && (bv_block_idx < nb_range_from_))
7035 bool skip_flag = sit.try_skip(bv_block_idx, nb_range_from_);
7038 bv_block_idx = sit.block_idx();
7039 BM_ASSERT(bv_block_idx <= nb_range_from_);
7040 BM_ASSERT(sit.state() == serial_iterator_type::e_blocks);
7044 case serial_iterator_type::e_bit_block:
7046 BM_ASSERT(sit.block_idx() == bv_block_idx);
7049 bm::word_t* blk = bman.get_block_ptr(i0, j0);
7062 blk = bman.make_bit_block(bv_block_idx);
7075 throw std::logic_error(err_msg());
7077 BM_THROW(BM_ERR_SERIALFORMAT);
7094 blk = bman.deoptimize_block(bv_block_idx);
7100 unsigned c = sit.get_bit_block(blk, temp_block, sop);
7102 if (exit_on_one && count)
7115 case serial_iterator_type::e_zero_blocks:
7117 BM_ASSERT(bv_block_idx == sit.block_idx());
7124 bv_block_idx = sit.skip_mono_blocks();
7130 bv_block_idx = sit.skip_mono_blocks();
7131 bman.set_all_zero(nb_start, bv_block_idx-1);
7142 bm::word_t* blk = bman.get_block_ptr(i0, j0);
7153 bman.zero_block(bv_block_idx);
7167 count += blk ? bman.block_bitcount(blk) : 0;
7168 if (exit_on_one && count)
7180 case serial_iterator_type::e_one_blocks:
7182 BM_ASSERT(bv_block_idx == sit.block_idx());
7185 bm::word_t* blk = bman.get_block_ptr(i0, j0);
7192 bman.set_block_all_set(bv_block_idx);
7200 bman.zero_block(bv_block_idx);
7204 if (++empty_op_cnt > 64)
7207 bool b = bv.find_reverse(last_id);
7211 if (last_nb < bv_block_idx)
7217 count += blk ? bman.block_bitcount(blk) : 0;
7225 blk = bman.deoptimize_block(bv_block_idx);
7256 bman.set_block_all_set(bv_block_idx);
7270 if (exit_on_one && count)
7275 case serial_iterator_type::e_gap_block:
7277 BM_ASSERT(bv_block_idx == sit.block_idx());
7281 const bm::word_t* blk = bman.get_block(i0, j0);
7283 sit.get_gap_block(gap_temp_block);
7301 if (exit_on_one && count)
7309 bman.zero_block(bv_block_idx);
7320 bv_block_idx, gap_temp_block, level);
7333 bv.combine_operation_with_block(bv_block_idx,
7341 bv.combine_operation_with_block(
7351 blk = bman.get_block_ptr(i0, j0);
7367 throw std::logic_error(err_msg());
7369 BM_THROW(BM_ERR_SERIALFORMAT);
7376 if (is_range_set_ && (bv_block_idx > nb_range_to_))
7390#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.
@ 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.
const unsigned char * skip_pos_
static const char * err_msg() BMNOEXCEPT
block_idx_type bookmark_idx_
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 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_
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_
void unset_range() BMNOEXCEPT
Disable range deserialization.
BV::blocks_manager_type blocks_manager_type
block_arridx_type gap_temp_block_
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)
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...
unsigned get_bit_block_COUNT_B(bm::word_t *dst_block, bm::word_t *tmp_block)
deseriaizer_base< DEC, block_idx_type > parent_type
unsigned char header_flag_
void next()
get next block
serial_stream_iterator(const unsigned char *buf)
block_idx_type mono_block_cnt_
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.
decoder_type & decoder()
Get low level access to the decoder (use carefully).
block_idx_type block_idx_
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 dec_size() const
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]
unsigned(serial_stream_iterator< DEC, BLOCK_IDX >::* get_bit_func_type)(bm::word_t *, bm::word_t *)
member function pointer for bitset-bitset get operations
iterator_state
iterator is a state machine, this enum encodes its key value
bool try_skip(block_idx_type nb, block_idx_type expect_nb) BMNOEXCEPT
void get_gap_block(bm::gap_word_t *dst_block)
deseriaizer_base< DEC, BLOCK_IDX >::decoder_type decoder_type
get_bit_func_type bit_func_table_[bm::set_END]
unsigned get_bit_block_COUNT_XOR(bm::word_t *dst_block, bm::word_t *tmp_block)
unsigned get_block_type() const BMNOEXCEPT
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)
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
serializer(bm::word_t *temp_block)
void reset_compression_stats() BMNOEXCEPT
Reset all accumulated compression statistics.
void bienc_arr_sblock(const bvector_type &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
void set_sim_model(const xor_sim_model_type *sim_model) BMNOEXCEPT
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
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
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
bm::bv_ref_vector< BV > bv_ref_vector_type
void byte_order_serialization(bool value) BMNOEXCEPT
unsigned char find_bit_best_encoding_l5(const bm::word_t *block) BMNOEXCEPT
void set_sparse_cutoff(unsigned cutoff) BMNOEXCEPT
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)
void encode_bit_array(const bm::word_t *block, bm::encoder &enc, bool inverted) BMNOEXCEPT
void interpolated_gap_bit_block(const bm::word_t *block, bm::encoder &enc) BMNOEXCEPT
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
unsigned get_compression_level() const BMNOEXCEPT
Get current compression level.
void reset_models() BMNOEXCEPT
const size_type * get_compression_stat() const BMNOEXCEPT
Return serialization counter vector.
void encode_xor_match_chain(bm::encoder &enc, const block_match_chain_type &mchain) BMNOEXCEPT
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
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
void add_model(unsigned char mod, unsigned score) BMNOEXCEPT
void bienc_gap_bit_block(const bm::word_t *block, bm::encoder &enc) BMNOEXCEPT
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)
void encode_bit_interval(const bm::word_t *blk, bm::encoder &enc, unsigned size_control) BMNOEXCEPT
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 bvector_type &bv, bm::encoder &enc) BMNOEXCEPT
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
bm::block_match_chain< size_type > block_match_chain_type
Parameters for XOR similarity search.