From 7dcec45b0339cd8b9b2bfab8ce1fc4c6080ea958 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 5 Jun 2023 11:43:14 -0400 Subject: WSS tests + bugfixes --- include/shard/WSS.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'include/shard') diff --git a/include/shard/WSS.h b/include/shard/WSS.h index 929f9df..bb7ee2a 100644 --- a/include/shard/WSS.h +++ b/include/shard/WSS.h @@ -74,7 +74,7 @@ public: friend class WSSQuery; WSS(MutableBuffer* buffer) - : m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0) { + : m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0), m_alias(nullptr), m_bf(nullptr) { size_t alloc_size = (buffer->get_record_count() * sizeof(Wrapped)) + (CACHELINE_SIZE - (buffer->get_record_count() * sizeof(Wrapped)) % CACHELINE_SIZE); assert(alloc_size % CACHELINE_SIZE == 0); @@ -117,12 +117,12 @@ public: } if (m_reccnt > 0) { - build_alias_structure(); + build_alias_structure(weights); } } WSS(WSS** shards, size_t len) - : m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0) { + : m_reccnt(0), m_tombstone_cnt(0), m_total_weight(0), m_alias(nullptr), m_bf(nullptr) { std::vector>> cursors; cursors.reserve(len); @@ -186,7 +186,7 @@ public: ~WSS() { if (m_data) free(m_data); - if (m_alias) free(m_alias); + if (m_alias) delete m_alias; if (m_bf) delete m_bf; } @@ -253,13 +253,16 @@ private: } void build_alias_structure(std::vector &weights) { + // normalize the weights vector + std::vector norm_weights(weights.size()); + for (size_t i=0; i* m_data; @@ -298,7 +301,6 @@ public: for (size_t i = 0; i <= state->cutoff; i++) { auto rec = buffer->get_data() + i; weights.push_back(rec->rec.weight); - state->records.push_back(*rec); tot_weight += rec->rec.weight; } -- cgit v1.2.3