From e69b88d2e0449432174740b6a4953079513f7db1 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Sun, 23 Jul 2023 14:32:08 -0400 Subject: Triespline RQ fixes --- include/shard/TrieSpline.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'include/shard') diff --git a/include/shard/TrieSpline.h b/include/shard/TrieSpline.h index b068313..d09d2a6 100644 --- a/include/shard/TrieSpline.h +++ b/include/shard/TrieSpline.h @@ -279,6 +279,10 @@ private: } + if (m_data[idx].rec.key > key && idx > 0 && m_data[idx-1].rec.key <= key) { + return idx-1; + } + return (m_data[idx].rec.key <= key) ? idx : m_reccnt; } @@ -329,10 +333,17 @@ 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 < ts->m_data + s->stop_idx) { + records.emplace_back(*ptr); + ptr++; } return records; @@ -356,12 +367,20 @@ public: } static std::vector merge(std::vector> &results, void *parms) { + size_t total = 0; + for (size_t i=0; i(); + } + std::vector output; + output.reserve(total); for (size_t i=0; i