From 438feac7e56fee425d9c6f1a43298ff9dc5b71d1 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Fri, 19 Apr 2024 17:38:16 -0400 Subject: Properly implemented support for iteratively decomposable problems --- include/query/rangecount.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include/query/rangecount.h') diff --git a/include/query/rangecount.h b/include/query/rangecount.h index 6c57809..c20feaa 100644 --- a/include/query/rangecount.h +++ b/include/query/rangecount.h @@ -134,12 +134,10 @@ public: return records; } - static std::vector merge(std::vector>> &results, void *parms) { - + static std::vector merge(std::vector>> &results, void *parms, std::vector &output) { R res; res.key = 0; res.value = 0; - std::vector output; output.emplace_back(res); for (size_t i=0; i *) state; delete s; } + + static bool repeat(void *parms, std::vector &results, std::vector states, void* buffer_state) { + return false; + } }; }} -- cgit v1.2.3 From 5576c5524b48e43e4d6070c28de7c3c66582ed97 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 1 May 2024 16:05:07 -0400 Subject: Query optimizations --- include/query/rangecount.h | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'include/query/rangecount.h') diff --git a/include/query/rangecount.h b/include/query/rangecount.h index c20feaa..5a18ed4 100644 --- a/include/query/rangecount.h +++ b/include/query/rangecount.h @@ -42,13 +42,7 @@ public: constexpr static bool SKIP_DELETE_FILTER=true; static void *get_query_state(S *shard, void *parms) { - auto res = new State(); - auto p = (Parms *) parms; - - res->start_idx = shard->get_lower_bound(p->lower_bound); - res->stop_idx = shard->get_record_count(); - - return res; + return nullptr; } static void* get_buffer_query_state(BufferView *buffer, void *parms) { @@ -74,37 +68,43 @@ public: res.rec.value = 0; // tombstones records.emplace_back(res); + + auto start_idx = shard->get_lower_bound(p->lower_bound); + auto stop_idx = shard->get_lower_bound(p->upper_bound); + /* * if the returned index is one past the end of the * records for the PGM, then there are not records * in the index falling into the specified range. */ - if (s->start_idx == shard->get_record_count()) { + if (start_idx == shard->get_record_count()) { return records; } - auto ptr = shard->get_record_at(s->start_idx); /* * roll the pointer forward to the first record that is * greater than or equal to the lower bound. */ - while(ptr < shard->get_data() + s->stop_idx && ptr->rec.key < p->lower_bound) { - ptr++; + auto recs = shard->get_data(); + while(start_idx < stop_idx && recs[start_idx].rec.key < p->lower_bound) { + start_idx++; } - while (ptr < shard->get_data() + s->stop_idx && ptr->rec.key <= p->upper_bound) { - if (!ptr->is_deleted()) { - if (ptr->is_tombstone()) { - records[0].rec.value++; - } else { - records[0].rec.key++; - } - } + while (stop_idx < shard->get_record_count() && recs[stop_idx].rec.key <= p->upper_bound) { + stop_idx++; + } + size_t idx = start_idx; + size_t ts_cnt = 0; - ptr++; + while (idx < stop_idx) { + ts_cnt += recs[idx].is_tombstone() * 2 + recs[idx].is_deleted(); + idx++; } + records[0].rec.key = idx - start_idx; + records[0].rec.value = ts_cnt; + return records; } @@ -150,8 +150,6 @@ public: } static void delete_query_state(void *state) { - auto s = (State *) state; - delete s; } static void delete_buffer_query_state(void *state) { -- cgit v1.2.3 From a23bc3341923509be9b2f587ece8cd5a650f6386 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 8 May 2024 13:20:44 -0400 Subject: TSParmsweep: enabled forcing a full buffer scan --- include/query/rangecount.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/query/rangecount.h') diff --git a/include/query/rangecount.h b/include/query/rangecount.h index 5a18ed4..5b95cdd 100644 --- a/include/query/rangecount.h +++ b/include/query/rangecount.h @@ -35,7 +35,7 @@ struct BufferState { : buffer(buffer) {} }; -template S> +template S, bool FORCE_SCAN=false> class Query { public: constexpr static bool EARLY_ABORT=false; @@ -119,8 +119,16 @@ public: res.rec.value = 0; // tombstones records.emplace_back(res); + size_t stop_idx; + if constexpr (FORCE_SCAN) { + stop_idx = s->buffer->get_capacity() / 2; + } else { + stop_idx = s->buffer->get_record_count(); + } + for (size_t i=0; ibuffer->get_record_count(); i++) { auto rec = s->buffer->get(i); + if (rec->rec.key >= p->lower_bound && rec->rec.key <= p->upper_bound && !rec->is_deleted()) { if (rec->is_tombstone()) { -- cgit v1.2.3