From a6c17386c4e76576f578795947c1763e06f06f46 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 7 Jun 2023 12:04:13 -0400 Subject: Bugfixes for query state processing function --- include/shard/WSS.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'include/shard/WSS.h') diff --git a/include/shard/WSS.h b/include/shard/WSS.h index 1069897..9300932 100644 --- a/include/shard/WSS.h +++ b/include/shard/WSS.h @@ -283,6 +283,8 @@ class WSSQuery { public: static void *get_query_state(WSS *wss, void *parms) { auto res = new WSSState(); + res->total_weight = wss->m_total_weight; + res->sample_size = 0; return res; } @@ -293,6 +295,7 @@ public: if constexpr (Rejection) { state->cutoff = buffer->get_record_count() - 1; state->max_weight = buffer->get_max_weight(); + state->total_weight = buffer->get_total_weight(); return state; } @@ -312,6 +315,7 @@ public: } state->alias = new Alias(weights); + state->total_weight = total_weight; return state; } @@ -320,13 +324,13 @@ public: auto p = (wss_query_parms *) query_parms; auto bs = (WSSBufferState *) buff_state; - std::vector shard_sample_sizes = {0}; + std::vector shard_sample_sizes(shard_states.size()+1, 0); size_t buffer_sz = 0; std::vector weights; weights.push_back(bs->total_weight); - decltype(R::weight) total_weight; + decltype(R::weight) total_weight = 0; for (auto &s : shard_states) { auto state = (WSSState *) s; total_weight += state->total_weight; @@ -350,18 +354,17 @@ public: bs->sample_size = buffer_sz; - size_t i=1; - for (auto &s : shard_states) { - auto state = (WSSState *) s; - state->sample_size = shard_sample_sizes[i++]; + for (size_t i=0; i *) shard_states[i]; + state->sample_size = shard_sample_sizes[i+1]; } } static std::vector> query(WSS *wss, void *q_state, void *parms) { - auto sample_size = ((WSSState *) q_state)->sample_size; auto rng = ((wss_query_parms *) parms)->rng; auto state = (WSSState *) q_state; + auto sample_size = state->sample_size; std::vector> result_set; -- cgit v1.2.3