summaryrefslogtreecommitdiffstats
path: root/include/shard/TrieSpline.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2023-07-23 14:32:08 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2023-07-23 14:34:25 -0400
commite69b88d2e0449432174740b6a4953079513f7db1 (patch)
treeec3a1a8bf6f7858e37c66ade47846f14d9d74350 /include/shard/TrieSpline.h
parentfc8b4c14bd2814447b5d3180c4ecf3742196c6bf (diff)
downloaddynamic-extension-e69b88d2e0449432174740b6a4953079513f7db1.tar.gz
Triespline RQ fixes
Diffstat (limited to 'include/shard/TrieSpline.h')
-rw-r--r--include/shard/TrieSpline.h33
1 files changed, 26 insertions, 7 deletions
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<R> merge(std::vector<std::vector<R>> &results, void *parms) {
+ size_t total = 0;
+ for (size_t i=0; i<results.size(); i++) {
+ total += results[i].size();
+ }
+
+ if (total == 0) {
+ return std::vector<R>();
+ }
+
std::vector<R> output;
+ output.reserve(total);
for (size_t i=0; i<results.size(); i++) {
- for (size_t j=0; j<results[i].size(); j++) {
- output.emplace_back(results[i][j]);
- }
+ std::move(results[i].begin(), results[i].end(), std::back_inserter(output));
}
return output;