1#ifndef BMSPARSEVEC_COMPR_H__INCLUDED__
2#define BMSPARSEVEC_COMPR_H__INCLUDED__
31#ifndef BM__H__INCLUDED__
34# error missing include (bm.h or bm64.h)
57template<
class Val,
class SV>
104 : csv_(csv), idx_(idx)
108 {
return bool(*
this) == bool(ref); }
155 {
return (pos_ == it.pos_) && (csv_ == it.csv_); }
159 {
return pos_ < it.pos_; }
161 {
return pos_ <= it.pos_; }
163 {
return pos_ > it.pos_; }
165 {
return pos_ >= it.pos_; }
205 n_buf_size = 1024 * 8
259 this->
flush(); sv_bi_ = bi.sv_bi_;
267 { this->
add(v);
return *
this; }
337 size_ = csv.size_; max_id_ = csv.max_id_;
338 in_sync_ = csv.in_sync_;
341 rs_idx_->copy_from(*(csv.rs_idx_));
358 size_ = csv.size_; max_id_ = csv.max_id_; in_sync_ = csv.in_sync_;
360 rs_idx_->copy_from(*(csv.rs_idx_));
584 bool zero_mem = true) const;
700 throw_no_rsc_index();
701 return const_iterator(
this);
712 {
return const_iterator(
this, idx); }
730 statistics* stat = 0);
836 {
return sv_.get_slice(i); }
839 {
return sv_.get_create_slice(i); }
842 {
return sv_.slice(i); }
848 {
return sv_.effective_slices(); }
879 {
return sv_.get_bmatrix(); }
885 {
return sv_.get_bmatrix(); }
893 {
return in_sync_ ? rs_idx_ : 0; }
896 { sv_.mark_null_idx(null_idx); }
925 sv_.resize_internal(sz);
937 bm::heap_matrix<
unsigned char, 1, 1,
958 void construct_rs_index();
960 void free_rs_index();
968 void throw_no_rsc_index();
982 bool is_dense_ =
false;
989template<
class Val,
class SV>
994: sv_(
bm::
use_null, ap, bv_max_size, alloc), in_sync_(false)
1000 construct_rs_index();
1005template<
class Val,
class SV>
1009 construct_rs_index();
1014 bool found = bv->find_reverse(max_id_);
1017 size_ = max_id_ + 1;
1024 size_ = max_id_ = 0;
1030template<
class Val,
class SV>
1038template<
class Val,
class SV>
1041: sv_(csv.sv_), size_(csv.size_), max_id_(csv.max_id_), in_sync_(csv.in_sync_)
1045 construct_rs_index();
1047 rs_idx_->copy_from(*(csv.rs_idx_));
1052template<
class Val,
class SV>
1057 max_id_(0), in_sync_(
false)
1062 size_ = csv.size_; max_id_ = csv.max_id_; in_sync_ = csv.in_sync_;
1063 rs_idx_ = csv.rs_idx_; csv.rs_idx_ = 0;
1069template<
class Val,
class SV>
1078template<
class Val,
class SV>
1085 BM_ASSERT(sv_.get_null_bvect()->none());
1087 size_ = max_id_ = 0;
1090 if (new_size >= size_)
1093 max_id_ = new_size - 1;
1105 max_id_ = new_size - 1;
1111 size_type new_sv_size = sv_.size() - clear_size;
1112 sv_.resize_internal(new_sv_size,
false);
1113 bv_null->clear_range(new_size,
bm::id_max-1);
1116 max_id_ = new_size - 1;
1125template<
class Val,
class SV>
1131 if (idx <= max_id_ && size_)
1133 sv_.throw_range_error(
"compressed sparse vector push_back() range error");
1140template<
class Val,
class SV>
1150template<
class Val,
class SV>
1156 bv_null->set_bit_no_check(idx);
1157 sv_.push_back_no_null(v);
1166template<
class Val,
class SV>
1172 bool found = bv_null->test(idx);
1176 size_type sv_idx = bv_null->count_range(0, idx);
1177 bv_null->clear_bit_no_check(idx);
1178 sv_.erase(--sv_idx,
false);
1186 size_ = max_id_ + 1;
1193template<
class Val,
class SV>
1198 bv_sub.bit_and(bv_idx, *bv_null);
1203 rank_compr.
compress(bv_sub_rsc, *bv_null, bv_sub);
1204 sv_.clear(bv_sub_rsc);
1213 size_type sv_idx = bv_null->count_range(0, idx);
1215 sv_.erase(--sv_idx,
false);
1217 bv_null->bit_sub(bv_sub);
1222template<
class Val,
class SV>
1228 bv_sub.bit_and(bv_idx, *bv_null);
1232 rank_compr.
compress(bv_sub_rsc, *bv_null, bv_sub);
1234 sv_.clear(bv_sub_rsc);
1239template<
class Val,
class SV>
1246 bool found = bv_null->test(idx);
1248 sv_idx = in_sync_ ? bv_null->count_to(idx, *rs_idx_)
1249 : bv_null->count_range(0, idx);
1253 sv_.inc_no_null(--sv_idx);
1257 sv_.insert_value_no_null(sv_idx, 1);
1258 bv_null->set_bit_no_check(idx);
1263 size_ = max_id_ + 1;
1271template<
class Val,
class SV>
1278 bool found = bv_null->test(idx);
1280 sv_idx = in_sync_ ? bv_null->count_to(idx, *rs_idx_)
1281 : bv_null->count_range(0, idx);
1285 sv_.inc_no_null(--sv_idx, v);
1289 sv_.insert_value_no_null(sv_idx, v);
1290 bv_null->set_bit_no_check(idx);
1295 size_ = max_id_ + 1;
1303template<
class Val,
class SV>
1310 sv_idx = in_sync_ ? bv_null->count_to(idx, *rs_idx_)
1311 : bv_null->count_range(0, idx);
1314 sv_.inc_no_null(sv_idx);
1316 sv_.inc_no_null(sv_idx, v);
1322template<
class Val,
class SV>
1329 bool found = bv_null->test(idx);
1331 sv_idx = in_sync_ ? bv_null->count_to(idx, *rs_idx_)
1332 : bv_null->count_range(0, idx);
1336 sv_.set_value_no_null(--sv_idx, v,
true);
1340 sv_.insert_value_no_null(sv_idx, v);
1341 bv_null->set_bit_no_check(idx);
1346 size_ = max_id_ + 1;
1354template<
class Val,
class SV>
1360 if (max_id_ != csv.max_id_ || size_ != csv.size_)
1362 bool same_sv = sv_.equal(csv.sv_);
1368template<
class Val,
class SV>
1372 max_id_ = size_ = 0;
1377 const bvector_type* bv_null_src = sv_src.get_null_bvector();
1385 sv_.clear_all(
true, 0);
1386 *bv_null = *bv_null_src;
1390 unsigned src_planes = sv_src.slices();
1391 for (
unsigned i = 0; i < src_planes; ++i)
1393 const bvector_type* bv_src_plane = sv_src.get_slice(i);
1397 rank_compr.
compress(*bv_plane, *bv_null, *bv_src_plane);
1409template<
class Val,
class SV>
1412 sv.clear_all(
true, 0);
1423 *bv_null = *bv_null_src;
1427 unsigned src_planes = sv_.slices();
1428 for (
unsigned i = 0; i < src_planes; ++i)
1430 if (
const bvector_type* bv_src_plane = sv_.get_slice(i))
1433 rank_compr.
decompress(*bv_plane, *bv_null, *bv_src_plane);
1436 sv.resize(this->
size());
1441template<
class Val,
class SV>
1444 if (in_sync_ && force ==
false)
1448 bv_null->build_rs_index(rs_idx_);
1449 sv_.is_ro_ = bv_null->is_ro();
1454 size_type cnt = size_ ? bv_null->count_range(0, size_-1, *rs_idx_)
1456 is_dense_ = (cnt == size_);
1464template<
class Val,
class SV>
1470 bool found = bv_null->find_reverse(max_id_);
1472 max_id_ = size_ = 0;
1474 size_ = max_id_ + 1;
1480template<
class Val,
class SV>
1488 BM_ASSERT(bv_null->get_bit(idx) ==
false);
1495 bool found = bv_null->test(idx);
1498 *idx_to = bv_null->count_range_no_check(0, idx);
1504template<
class Val,
class SV>
1519 BM_ASSERT(bv_null->get_bit(idx) ==
false);
1522 *idx_to = bv_null->count_to_test(idx, *rs_idx_);
1523 return bool(*idx_to);
1528template<
class Val,
class SV>
1537 copy_sz = bv_null->count_range(from, to, *rs_idx_);
1539 copy_sz = bv_null->count_range(from, to);
1544 sv_left = bv_null->rank_corrected(from, *rs_idx_);
1547 sv_left = bv_null->count_range(0, from);
1548 bool tl = bv_null->test(from);
1552 *idx_from = sv_left; *idx_to = sv_left + copy_sz - 1;
1559template<
class Val,
class SV>
1565 sv_.throw_range_error(
"compressed collection access error");
1567 bool found =
resolve(idx, &sv_idx);
1570 sv_.throw_range_error(
"compressed collection item not found");
1572 return sv_.at(--sv_idx);
1577template<
class Val,
class SV>
1582 bool found =
resolve(idx, &sv_idx);
1586 return sv_.get(--sv_idx);
1591template<
class Val,
class SV>
1597 bool found =
resolve(idx, &sv_idx);
1601 return sv_.get_unsigned_bits(--sv_idx, N_bits);
1606template<
class Val,
class SV>
1613 v = sv_.get(--sv_idx);
1619template<
class Val,
class SV>
1627 v = sv_.get(--sv_idx);
1633template<
class Val,
class SV>
1638 return !(bv_null->test(idx));
1643template<
class Val,
class SV>
1648 sv_.optimize(temp_block, opt_mode, (
typename sparse_vector_type::statistics*)st);
1653 (
sizeof(
typename rs_index_type::size_type)
1654 +
sizeof(
typename rs_index_type::sb_pair_type));
1662template<
class Val,
class SV>
1665 sv_.clear_all(free_mem, 0);
1666 in_sync_ =
false; max_id_ = size_ = 0;
1671template<
class Val,
class SV>
1676 sv_.calc_stat((
typename sparse_vector_type::statistics*)st);
1680 st->memory_used += rs_idx_->get_total() *
1681 (
sizeof(
typename rs_index_type::size_type)
1682 +
sizeof(
typename rs_index_type::sb_pair_type));
1688template<
class Val,
class SV>
1692 return sv_.get_null_bvector();
1697template<
class Val,
class SV>
1706 b = bv_null->select(rank, idx, *rs_idx_);
1708 b = bv_null->find_rank(rank, 0, idx);
1714template<
class Val,
class SV>
1715void rsc_sparse_vector<Val, SV>::throw_no_rsc_index()
1718 throw std::domain_error(
"Rank-Select index not constructed, call sync() first");
1727template<
class Val,
class SV>
1732 bool zero_mem)
const
1737 throw_no_rsc_index();
1742 if (idx_from >= this->size())
1747 if ((idx_from +
size) > this->size())
1748 size = this->size() - idx_from;
1751 size_type rank = bv_null->rank_corrected(idx_from, *rs_idx_);
1753 BM_ASSERT(rank == bv_null->count_range(0, idx_from) - bv_null->test(idx_from));
1775 arr[i++] = it.value();
1787template<
class Val,
class SV>
1795 if (!
size || (idx_from >= this->
size()))
1805 if ((idx_from +
size) > this->
size())
1812 size_type rank = bv_null->rank_corrected(idx_from, *rs_idx_);
1814 BM_ASSERT(rank == bv_null->count_range(0, idx_from) - bv_null->test(idx_from));
1821 if (idx_from +
size <= i)
1825 bv_null->count_range_no_check(idx_from, idx_from +
size - 1, *rs_idx_);
1828 auto ex_sz = sv_.decode(arr_buf_tmp, rank, extract_cnt,
true);
1829 BM_ASSERT(ex_sz == extract_cnt); (void) ex_sz;
1831 for (i = 0; i < extract_cnt; ++i)
1835 arr[en_idx-idx_from] = arr_buf_tmp[i];
1845template<
class Val,
class SV>
1860 arr[0] = this->
get(idx[0]);
1870 idx_tmp_buf[i] = idx[i];
1888 idx_tmp_buf[i] = sv_idx-1;
1901 size = sv_.gather(arr, idx_tmp_buf,
size, sorted_idx);
1908template<
class Val,
class SV>
1909void rsc_sparse_vector<Val, SV>::construct_rs_index()
1914 rs_idx_ =
new(rs_idx_) rs_index_type();
1919template<
class Val,
class SV>
1920void rsc_sparse_vector<Val, SV>::free_rs_index()
1924 rs_idx_->~rs_index_type();
1931template<
class Val,
class SV>
1939 if (left >= csv.
size())
1942 size_ = csv.size_; max_id_ = csv.max_id_;
1945 const bvector_type* arg_bv_null = csv.sv_.get_null_bvector();
1947 bool range_valid = csv.
resolve_range(left, right, &sv_left, &sv_right);
1950 sv_.clear_all(
true, 0); sv_.resize(size_);
1952 bv_null->copy_range(*arg_bv_null, 0, right);
1956 bv_null->copy_range(*arg_bv_null, 0, right);
1957 sv_.copy_range(csv.sv_, sv_left, sv_right,
bm::no_null);
1963template<
class Val,
class SV>
1967 BM_ASSERT(sv_.get_null_bvector()->equal(*csv.sv_.get_null_bvector()));
1974template<
class Val,
class SV>
1987 return bv_null->count_range_no_check(left, right);
1989 return bv_null->count_range_no_check(left, right, *rs_idx_);
1997template<
class Val,
class SV>
2005template<
class Val,
class SV>
2011 sv_bi_.disable_set_null();
2016template<
class Val,
class SV>
2027template<
class Val,
class SV>
2035template<
class Val,
class SV>
2042 sv_bi_.add_value_no_null(v);
2045 bv_null->set_bit_no_check(csv_->size_);
2053template<
class Val,
class SV>
2059 csv_->max_id_++; csv_->size_++;
2064template<
class Val,
class SV>
2071 csv_->max_id_+=count;
2077template<
class Val,
class SV>
2081 csv_->in_sync_ =
false;
2088template<
class Val,
class BV>
2090: csv_(0), pos_(
bm::
id_max), buf_ptr_(0)
2095template<
class Val,
class SV>
2098: csv_(it.csv_), pos_(it.pos_), buf_ptr_(0)
2103template<
class Val,
class SV>
2107: csv_(csv), buf_ptr_(0)
2115template<
class Val,
class SV>
2119: csv_(csv), buf_ptr_(0)
2127template<
class Val,
class SV>
2136template<
class Val,
class SV>
2142 if (pos_ >= csv_->size())
2150 if (buf_ptr_ - ((
value_type*)vbuffer_.data()) >= n_buf_size)
2158template<
class Val,
class SV>
2167 vbuffer_.reserve(n_buf_size *
sizeof(
value_type));
2168 tbuffer_.reserve(n_buf_size *
sizeof(
value_type));
2172 csv_->decode_buf(buf_ptr_, tmp_buf_ptr, pos_, n_buf_size,
true);
2180template<
class Val,
class SV>
2191 if (++buf_ptr_ < buf_end)
2196 if (pos_ >= csv_->size())
2201 if (buf_ptr_ >= buf_end)
2208template<
class Val,
class SV>
2211 return csv_->is_null(pos_);
#define BM_ASSERT_THROW(x, xerrcode)
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
static unsigned slices() BMNOEXCEPT
get total number of bit-planes in the vector
static value_type u2s(unsigned_value_type v) BMNOEXCEPT
Convert unsigned value type to signed representation.
static unsigned_value_type s2u(value_type v) BMNOEXCEPT
Convert signed value type to unsigned representation.
static unsigned stored_slices() BMNOEXCEPT
Number of stored bit-planes (value planes + extra.
Constant iterator designed to enumerate "ON" bits.
size_type value() const BMNOEXCEPT
Get current position (value).
bool advance() BMNOEXCEPT
bool valid() const BMNOEXCEPT
Checks if iterator is still valid.
optmode
Optimization mode Every next level means additional checks (better compression vs time).
@ opt_compress
compress blocks when possible (GAP/prefix sum)
allocator_type::allocator_pool_type allocator_pool_type
rs_index< allocator_type > rs_index_type
Algorithms for rank compression of bit-vector.
void decompress(BV &bv_target, const BV &bv_idx, const BV &bv_src)
Rank decompression.
void compress(BV &bv_target, const BV &bv_idx, const BV &bv_src)
Rank compression algorithm based on two palallel iterators/enumerators set of source vector gets re-m...
void flush()
flush the accumulated buffer
rsc_sparse_vector_type * rsc_sparse_vector_type_ptr
rsc_sparse_vector_type::sparse_vector_type sparse_vector_type
add value to the buffer without changing the NULL vector
void add(value_type v)
add value to the container
std::output_iterator_tag iterator_category
rsc_sparse_vector_type::bvector_type bvector_type
back_insert_iterator & operator=(value_type v)
push value to the vector
rsc_sparse_vector< Val, SV > rsc_sparse_vector_type
rsc_sparse_vector_type::size_type size_type
rsc_sparse_vector_type::value_type value_type
back_insert_iterator() BMNOEXCEPT
back_insert_iterator & operator*()
noop
back_insert_iterator & operator++(int)
noop
void add_null() BMNOEXCEPT
add NULL (no-value) to the container
back_insert_iterator & operator++()
noop
sparse_vector_type::back_insert_iterator sparse_vector_bi
Const iterator to traverse the rsc sparse vector.
const_iterator & operator++() BMNOEXCEPT
Advance to the next available value.
bool advance() BMNOEXCEPT
advance iterator forward by one
rsc_sparse_vector< Val, SV > rsc_sparse_vector_type
void skip_zero_values() BMNOEXCEPT
size_type pos() const BMNOEXCEPT
Current position (index) in the vector.
rsc_sparse_vector_type::value_type value_type
bool operator!=(const const_iterator &it) const BMNOEXCEPT
bool operator<=(const const_iterator &it) const BMNOEXCEPT
bool operator>(const const_iterator &it) const BMNOEXCEPT
bm::byte_buffer< allocator_type > buffer_type
void go_to(size_type pos) BMNOEXCEPT
re-position to a specified position
bool operator<(const const_iterator &it) const BMNOEXCEPT
bool operator==(const const_iterator &it) const BMNOEXCEPT
bool is_null() const BMNOEXCEPT
Get NULL status.
rsc_sparse_vector_type::bvector_type bvector_type
std::input_iterator_tag iterator_category
rsc_sparse_vector_type * rsc_sparse_vector_type_ptr
const_iterator & operator++(int)
Advance to the next available value.
bool valid() const BMNOEXCEPT
Returns true if iterator is at a valid position.
void invalidate() BMNOEXCEPT
Invalidate current iterator.
bool operator>=(const const_iterator &it) const BMNOEXCEPT
friend class rsc_sparse_vector
rsc_sparse_vector_type::size_type size_type
const_iterator() BMNOEXCEPT
bvector_type::allocator_type::allocator_pool_type allocator_pool_type
value_type operator*() const
Get current position (value).
value_type value() const
Get current position (value).
bvector_type::allocator_type allocator_type
bool operator==(const reference &ref) const BMNOEXCEPT
bool is_null() const BMNOEXCEPT
reference(rsc_sparse_vector< Val, SV > &csv, size_type idx) BMNOEXCEPT
static constexpr bool is_str() BMNOEXCEPT
static constexpr bool is_compressed() BMNOEXCEPT
various type traits
static unsigned stored_slices()
Number of stored bit-slices (value slices + extra.
bvector_type * bvector_type_ptr
bool try_get(size_type idx, value_type &v) const BMNOEXCEPT
get specified element with NOT NULL check
void clear_all(bool free_mem, unsigned) BMNOEXCEPT
resize to zero, free memory
friend class sparse_vector_scanner
bool resolve(size_type idx, size_type *idx_to) const BMNOEXCEPT
Resolve logical address to access via rank compressed address.
void load_from(const sparse_vector_type &sv_src)
Load compressed vector from a sparse vector (with NULLs).
rsc_sparse_vector< Val, SV > & operator=(rsc_sparse_vector< Val, SV > &&csv) BMNOEXCEPT
const sparse_vector_type & get_sv() const BMNOEXCEPT
access dense vector
bool resolve_sync(size_type idx, size_type *idx_to) const BMNOEXCEPT
const bmatrix_type & get_bmatrix() const BMNOEXCEPT
void merge_not_null(rsc_sparse_vector< Val, SV > &csv)
merge two vectors (argument gets destroyed) It is important that both vectors have the same NULL vect...
size_type decode(value_type *arr, size_type idx_from, size_type size, bool zero_mem=true) const
void freeze()
Turn sparse vector into immutable mode Read-only (immutable) vector uses less memory and allows faste...
void push_back(size_type idx, value_type v)
set specified element with bounds checking and automatic resize
void clear(const bvector_type &bv_idx)
Set vector elements spcified by argument bit-vector to zero Note that set to 0 elements are NOT going...
back_insert_iterator get_back_inserter()
void load_to(sparse_vector_type &sv) const
Exort compressed vector to a sparse vector (with NULLs).
SV::bmatrix_type bmatrix_type
void set(size_type idx, value_type v)
set specified element with bounds checking and automatic resize
bm::heap_matrix< unsigned char, 1, 1, typename bvector_type::allocator_type > remap_matrix_type
unused remap matrix type for compatibility with the sparse serializer
const_iterator end() const BMNOEXCEPT
Provide const iterator access to the end.
value_type at(size_type idx) const
access specified element with bounds checking
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, statistics *stat=0)
run memory optimization for all vector slices
void sync(bool force)
Re-calculate rank-select index for faster access to vector.
size_type count_range_notnull(size_type left, size_type right) const BMNOEXCEPT
size_type effective_vector_max() const BMNOEXCEPT
Always 1 (non-matrix type).
SV::unsigned_value_type unsigned_value_type
bvector_type_ptr slice(unsigned i)
rsc_sparse_vector(bm::null_support null_able=bm::use_null, allocation_policy_type ap=allocation_policy_type(), size_type bv_max_size=bm::id_max, const allocator_type &alloc=allocator_type())
void push_back_null()
push back NULL value
void unsync() BMNOEXCEPT
Unsync the prefix sum table.
bool resolve_range(size_type from, size_type to, size_type *idx_from, size_type *idx_to) const BMNOEXCEPT
size_type effective_size() const BMNOEXCEPT
size of internal dense vector
static unsigned_value_type s2u(value_type v) BMNOEXCEPT
Convert signed value type to unsigned representation.
void set_remap() BMNOEXCEPT
void set_null(size_type idx)
set specified element to NULL RSC vector actually erases element when it is set to NULL (expensive).
void inc_not_null(size_type idx, value_type v)
increment specified element by one, element MUST be NOT NULL Faster than just inc() if element is NUL...
const remap_matrix_type * get_remap_matrix() const
friend class sparse_vector_serializer
bvector_type_const_ptr get_slice(unsigned i) const BMNOEXCEPT
get access to bit-plane, function checks and creates a plane
void resize(size_type new_size)
void resize_internal(size_type sz)
size_type decode_buf(value_type *arr, value_type *arr_buf_tmp, size_type idx_from, size_type size, bool zero_mem=true) const BMNOEXCEPT
size_type size_internal() const BMNOEXCEPT
SV::const_iterator sparse_vector_const_iterator
bvector_type_ptr get_create_slice(unsigned i)
constexpr bool is_remap() const BMNOEXCEPT
bool equal(const rsc_sparse_vector< Val, SV > &csv) const BMNOEXCEPT
check if another vector has the same content
friend class sparse_vector_deserializer
value_type get(size_type idx) const BMNOEXCEPT
get specified element without bounds checking
bool empty() const BMNOEXCEPT
const value_type & const_reference
bmatrix_type & get_bmatrix() BMNOEXCEPT
const_iterator get_const_iterator(size_type idx) const BMNOEXCEPT
Get const_itertor re-positioned to specific element.
const bvector_type * bvector_type_const_ptr
size_t remap_size() const BMNOEXCEPT
void sync()
Re-calculate prefix sum table used for rank search (if necessary).
const unsigned char * get_remap_buffer() const BMNOEXCEPT
unsigned char * init_remap_buffer() BMNOEXCEPT
void set_null(const bvector_type &bv_idx)
Set NULL all elements set as 1 in the argument vector.
bool is_null(size_type idx) const BMNOEXCEPT
test if specified element is NULL
static value_type u2s(unsigned_value_type v) BMNOEXCEPT
void mark_null_idx(unsigned null_idx) BMNOEXCEPT
void calc_stat(struct rsc_sparse_vector< Val, SV >::statistics *st) const BMNOEXCEPT
Calculates memory statistics.
bvector_type::allocator_type allocator_type
rsc_sparse_vector(rsc_sparse_vector< Val, SV > &&csv) BMNOEXCEPT
const bvector_type * get_null_bvector() const BMNOEXCEPT
Get bit-vector of assigned values (or NULL).
void clear() BMNOEXCEPT
resize to zero, free memory
void push_back(value_type v)
add element with automatic resize
unsigned effective_slices() const BMNOEXCEPT
bool try_get_sync(size_type idx, value_type &v) const BMNOEXCEPT
get specified element with NOT NULL check Caller guarantees that the vector is in sync mode (RS-index...
bvector_type::rs_index_type rs_index_type
bool is_sync() const BMNOEXCEPT
returns true if prefix sum table is in sync with the vector
bool find_rank(size_type rank, size_type &idx) const BMNOEXCEPT
remap_matrix_type * get_remap_matrix()
size_type size() const BMNOEXCEPT
return size of the vector
bvector_type::enumerator bvector_enumerator_type
const rs_index_type * get_RS() const BMNOEXCEPT
static unsigned slices() BMNOEXCEPT
get total number of bit-slices in the vector
unsigned_value_type get_unsigned_bits(size_type idx, size_type N_bits) const BMNOEXCEPT
Get raw unsigned value first N bits.
void push_back_null(size_type count)
push back specified amount of NULL values
bool in_sync() const BMNOEXCEPT
returns true if prefix sum table is in sync with the vector
void copy_range(const rsc_sparse_vector< Val, SV > &csv, size_type left, size_type right)
copy range of values from another sparse vector
void inc(size_type idx)
increment specified element by one
size_type gather(value_type *arr, const size_type *idx, size_type *idx_tmp_buf, size_type size, bm::sort_order sorted_idx) const
void push_back_no_check(size_type idx, value_type v)
bool is_ro() const BMNOEXCEPT
Returns true if vector is read-only.
bvector_type::allocation_policy allocation_policy_type
SV::bvector_type bvector_type
void inc(size_type idx, value_type v)
increment specified element by one
void sync_size() BMNOEXCEPT
recalculate size to exclude tail NULL elements After this call size() will return the true size of th...
const_iterator begin() const
Provide const iterator access to container content.
sort_order
Sort order declaration.
null_support
NULL-able value support.
@ BM_SORTED
input set is sorted (ascending order)
@ BM_UNKNOWN
sort order unknown
@ use_null
support "non-assigned" or "NULL" logic
@ no_null
do not support NULL values
void aligned_free(void *ptr) BMNOEXCEPT
Aligned free.
void * aligned_new_malloc(size_t size)
Aligned malloc (unlike classic malloc it throws bad_alloc exception).
BMFORCEINLINE void xor_swap(W &x, W &y) BMNOEXCEPT
XOR swap two variables.
unsigned long long int id64_t
const unsigned rs3_border0
bv_statistics() BMNOEXCEPT
size_t memory_used
memory usage for all blocks and service tables