mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-15 15:26:19 -04:00
Fix segmenter for the case when segmenting is disable
This commit is contained in:
parent
bad2c5e057
commit
b101694d06
@ -178,6 +178,7 @@ class alignas(64) bloom_filter {
|
|||||||
explicit bloom_filter(size_t size)
|
explicit bloom_filter(size_t size)
|
||||||
: index_mask_{(std::max(size, value_mask + 1) >> index_shift) - 1}
|
: index_mask_{(std::max(size, value_mask + 1) >> index_shift) - 1}
|
||||||
, size_{std::max(size, value_mask + 1)} {
|
, size_{std::max(size, value_mask + 1)} {
|
||||||
|
if (size > 0) {
|
||||||
if (size & (size - 1)) {
|
if (size & (size - 1)) {
|
||||||
throw std::runtime_error("size must be a power of two");
|
throw std::runtime_error("size must be a power of two");
|
||||||
}
|
}
|
||||||
@ -188,8 +189,13 @@ class alignas(64) bloom_filter {
|
|||||||
}
|
}
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
~bloom_filter() { boost::alignment::aligned_free(bits_); }
|
~bloom_filter() {
|
||||||
|
if (bits_) {
|
||||||
|
boost::alignment::aligned_free(bits_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void add(size_t ix) {
|
void add(size_t ix) {
|
||||||
auto bits = bits_;
|
auto bits = bits_;
|
||||||
@ -225,7 +231,7 @@ class alignas(64) bloom_filter {
|
|||||||
bits_type* begin() { return bits_; }
|
bits_type* begin() { return bits_; }
|
||||||
bits_type* end() { return bits_ + (size_ >> index_shift); }
|
bits_type* end() { return bits_ + (size_ >> index_shift); }
|
||||||
|
|
||||||
bits_type* bits_;
|
bits_type* bits_{nullptr};
|
||||||
size_t const index_mask_;
|
size_t const index_mask_;
|
||||||
size_t const size_;
|
size_t const size_;
|
||||||
};
|
};
|
||||||
@ -682,12 +688,16 @@ class segmenter_ final : public segmenter::impl, private SegmentingPolicy {
|
|||||||
void segment_and_add_data(chunkable& chkable, size_t size_in_frames);
|
void segment_and_add_data(chunkable& chkable, size_t size_in_frames);
|
||||||
|
|
||||||
size_t bloom_filter_size(const segmenter::config& cfg) const {
|
size_t bloom_filter_size(const segmenter::config& cfg) const {
|
||||||
|
if constexpr (is_segmentation_enabled()) {
|
||||||
auto hash_count =
|
auto hash_count =
|
||||||
std::bit_ceil(std::max<size_t>(1, cfg.max_active_blocks) *
|
std::bit_ceil(std::max<size_t>(1, cfg.max_active_blocks) *
|
||||||
(block_size_in_frames(cfg) / window_step(cfg)));
|
(block_size_in_frames(cfg) / window_step(cfg)));
|
||||||
return (static_cast<size_t>(1) << cfg.bloom_filter_size) * hash_count;
|
return (static_cast<size_t>(1) << cfg.bloom_filter_size) * hash_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static size_t window_size(const segmenter::config& cfg) {
|
static size_t window_size(const segmenter::config& cfg) {
|
||||||
return cfg.blockhash_window_size > 0
|
return cfg.blockhash_window_size > 0
|
||||||
? static_cast<size_t>(1) << cfg.blockhash_window_size
|
? static_cast<size_t>(1) << cfg.blockhash_window_size
|
||||||
@ -972,10 +982,12 @@ void segmenter_<LoggerPolicy, SegmentingPolicy>::append_to_block(
|
|||||||
blocks_.pop_front();
|
blocks_.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if constexpr (is_segmentation_enabled()) {
|
||||||
global_filter_.clear();
|
global_filter_.clear();
|
||||||
for (auto const& b : blocks_) {
|
for (auto const& b : blocks_) {
|
||||||
global_filter_.merge(b.filter());
|
global_filter_.merge(b.filter());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add_new_block(blocks_, LOG_GET_LOGGER, repeating_sequence_hash_values_,
|
add_new_block(blocks_, LOG_GET_LOGGER, repeating_sequence_hash_values_,
|
||||||
repeating_collisions_, blkmgr_->get_logical_block(),
|
repeating_collisions_, blkmgr_->get_logical_block(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user