|
24 | 24 |
|
25 | 25 | namespace datasketches { |
26 | 26 | template<class Derived, typename Allocator> |
27 | | -CollapsingDenseStore<Derived, Allocator>::CollapsingDenseStore(size_type max_num_bins): DenseStore<Derived, Allocator>(), max_num_bins(max_num_bins), is_collapsed(false) {} |
| 27 | +CollapsingDenseStore<Derived, Allocator>::CollapsingDenseStore(size_type max_num_bins): |
| 28 | + DenseStore<Derived, Allocator>(), |
| 29 | + max_num_bins(max_num_bins), |
| 30 | + is_collapsed(false) {} |
28 | 31 |
|
29 | 32 | template<class Derived, typename Allocator> |
30 | 33 | CollapsingDenseStore<Derived, Allocator>& CollapsingDenseStore<Derived, Allocator>::operator=(const CollapsingDenseStore<Derived, Allocator>& other) { |
@@ -76,5 +79,26 @@ Derived CollapsingDenseStore<Derived, Allocator>::deserialize(std::istream& is) |
76 | 79 | return store; |
77 | 80 | } |
78 | 81 |
|
| 82 | +template<class Derived, typename Allocator> |
| 83 | +int CollapsingDenseStore<Derived, Allocator>::get_serialized_size_bytes() const { |
| 84 | + int size_bytes = 0; |
| 85 | + size_bytes += sizeof(max_num_bins); |
| 86 | + size_bytes += sizeof(is_collapsed); |
| 87 | + size_bytes += sizeof(this->min_index); |
| 88 | + size_bytes += sizeof(this->max_index); |
| 89 | + size_bytes += sizeof(size_type); |
| 90 | + |
| 91 | + size_type non_empty_bins = 0; |
| 92 | + for (const double& count : this->bins) { |
| 93 | + non_empty_bins += (count > 0.0); |
| 94 | + } |
| 95 | + |
| 96 | + size_bytes += sizeof(non_empty_bins); |
| 97 | + size_bytes += non_empty_bins * sizeof(size_type); |
| 98 | + size_bytes += non_empty_bins * sizeof(double); |
| 99 | + |
| 100 | + return size_bytes; |
| 101 | +} |
| 102 | + |
79 | 103 | } |
80 | 104 | #endif //COLLAPSING_DENSE_STORE_IMPL_HPP |
0 commit comments