summaryrefslogtreecommitdiffstats
path: root/include/shard/WIRS.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/shard/WIRS.h')
-rw-r--r--include/shard/WIRS.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/include/shard/WIRS.h b/include/shard/WIRS.h
index 9760443..1a63092 100644
--- a/include/shard/WIRS.h
+++ b/include/shard/WIRS.h
@@ -98,9 +98,9 @@ public:
WIRS(MutableBuffer<R>* buffer)
: m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0), m_root(nullptr) {
- size_t alloc_size = (buffer->get_record_count() * sizeof(Wrapped<R>)) + (CACHELINE_SIZE - (buffer->get_record_count() * sizeof(Wrapped<R>)) % CACHELINE_SIZE);
- assert(alloc_size % CACHELINE_SIZE == 0);
- m_data = (Wrapped<R>*)std::aligned_alloc(CACHELINE_SIZE, alloc_size);
+ m_alloc_size = (buffer->get_record_count() * sizeof(Wrapped<R>)) + (CACHELINE_SIZE - (buffer->get_record_count() * sizeof(Wrapped<R>)) % CACHELINE_SIZE);
+ assert(m_alloc_size % CACHELINE_SIZE == 0);
+ m_data = (Wrapped<R>*)std::aligned_alloc(CACHELINE_SIZE, m_alloc_size);
m_bf = new BloomFilter<R>(BF_FPR, buffer->get_tombstone_count(), BF_HASH_FUNCS);
@@ -168,9 +168,9 @@ public:
m_bf = new BloomFilter<R>(BF_FPR, tombstone_count, BF_HASH_FUNCS);
- size_t alloc_size = (attemp_reccnt * sizeof(Wrapped<R>)) + (CACHELINE_SIZE - (attemp_reccnt * sizeof(Wrapped<R>)) % CACHELINE_SIZE);
- assert(alloc_size % CACHELINE_SIZE == 0);
- m_data = (Wrapped<R>*)std::aligned_alloc(CACHELINE_SIZE, alloc_size);
+ m_alloc_size = (attemp_reccnt * sizeof(Wrapped<R>)) + (CACHELINE_SIZE - (attemp_reccnt * sizeof(Wrapped<R>)) % CACHELINE_SIZE);
+ assert(m_alloc_size % CACHELINE_SIZE == 0);
+ m_data = (Wrapped<R>*)std::aligned_alloc(CACHELINE_SIZE, m_alloc_size);
while (pq.size()) {
auto now = pq.peek();
@@ -253,7 +253,7 @@ public:
size_t get_memory_usage() {
- return 0;
+ return m_alloc_size + m_node_cnt * sizeof(wirs_node<Wrapped<R>>);
}
private:
@@ -338,7 +338,7 @@ private:
if (sum) w /= sum;
else w = 1.0 / node_weights.size();
-
+ m_node_cnt += 1;
size_t mid = (low + high) / 2;
return new wirs_node<R>{construct_wirs_node(weights, low, mid),
construct_wirs_node(weights, mid + 1, high),
@@ -361,6 +361,8 @@ private:
size_t m_reccnt;
size_t m_tombstone_cnt;
size_t m_group_size;
+ size_t m_alloc_size;
+ size_t m_node_cnt;
BloomFilter<R> *m_bf;
};