From f39e512ae3848abd1d3c68349c1a8fbe97be91b5 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 3 Jul 2023 15:19:20 -0400 Subject: Fixed query errors --- include/framework/DynamicExtension.h | 2 +- include/shard/PGM.h | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/framework/DynamicExtension.h b/include/framework/DynamicExtension.h index 544cd8f..242db8e 100644 --- a/include/framework/DynamicExtension.h +++ b/include/framework/DynamicExtension.h @@ -130,7 +130,7 @@ public: // Execute the query for each shard for (size_t i=0; i key && idx > 0 && m_data[idx-1].rec.key <= key) { + return idx-1; + } + return (m_data[idx].rec.key >= key) ? idx : m_reccnt; } +private: Wrapped* m_data; size_t m_reccnt; size_t m_tombstone_cnt; @@ -307,10 +311,16 @@ public: } auto ptr = ts->get_record_at(s->start_idx); - size_t i = 0; - while (ptr[i].rec.key <= p->upper_bound && i < s->stop_idx - s->start_idx) { - records.emplace_back(ptr[i]); - i++; + + // roll the pointer forward to the first record that is + // greater than or equal to the lower bound. + while(ptr->rec.key < p->lower_bound) { + ptr++; + } + + while (ptr->rec.key <= p->upper_bound && ptr < ptr + s->stop_idx) { + records.emplace_back(*ptr); + ptr++; } return records; @@ -326,10 +336,8 @@ public: if (rec->rec.key >= p->lower_bound && rec->rec.key <= p->upper_bound) { records.emplace_back(*rec); } - } - return records; } -- cgit v1.2.3