summaryrefslogtreecommitdiffstats
path: root/include/shard/PGM.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2023-07-03 15:19:20 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2023-07-03 15:19:20 -0400
commitf39e512ae3848abd1d3c68349c1a8fbe97be91b5 (patch)
treeaa95fdf6e496556ef7490909de1191a3f81a5584 /include/shard/PGM.h
parent8ecf203a77a897b25af084ceefd82023bfcc1c35 (diff)
downloaddynamic-extension-f39e512ae3848abd1d3c68349c1a8fbe97be91b5.tar.gz
Fixed query errors
Diffstat (limited to 'include/shard/PGM.h')
-rw-r--r--include/shard/PGM.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/include/shard/PGM.h b/include/shard/PGM.h
index 1622d7e..f3f5106 100644
--- a/include/shard/PGM.h
+++ b/include/shard/PGM.h
@@ -226,7 +226,6 @@ public:
return m_pgm.size_in_bytes();
}
-private:
size_t get_lower_bound(const K& key) const {
auto bound = m_pgm.search(key);
size_t idx = bound.lo;
@@ -257,9 +256,14 @@ 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;
}
+private:
Wrapped<R>* 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;
}