diff options
| author | Dong Xie <dongx@psu.edu> | 2023-07-28 02:31:52 -0400 |
|---|---|---|
| committer | Dong Xie <dongx@psu.edu> | 2023-07-28 02:31:52 -0400 |
| commit | b0dea94f86ba96a7c319764d6b7d920d202ffa7e (patch) | |
| tree | 0cf79186457a42ece044115d25d4f5fe97c1fec7 /include/shard/TrieSpline.h | |
| parent | bd5295f1163839c23d6da0d8f353bfc308e272a4 (diff) | |
| download | dynamic-extension-b0dea94f86ba96a7c319764d6b7d920d202ffa7e.tar.gz | |
Change PGM to range count.
Diffstat (limited to 'include/shard/TrieSpline.h')
| -rw-r--r-- | include/shard/TrieSpline.h | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/include/shard/TrieSpline.h b/include/shard/TrieSpline.h index 7d1a90d..973b684 100644 --- a/include/shard/TrieSpline.h +++ b/include/shard/TrieSpline.h @@ -325,7 +325,8 @@ public: } static std::vector<Wrapped<R>> query(TrieSpline<R> *ts, void *q_state, void *parms) { - std::vector<Wrapped<R>> records; + //std::vector<Wrapped<R>> records; + size_t tot = 0; auto p = (ts_range_query_parms<R> *) parms; auto s = (TrieSplineState<R> *) q_state; @@ -333,7 +334,7 @@ public: // records for the TrieSpline, then there are not records // in the index falling into the specified range. if (s->start_idx == ts->get_record_count()) { - return records; + return {}; } auto ptr = ts->get_record_at(s->start_idx); @@ -346,32 +347,39 @@ public: while (ptr->rec.key <= p->upper_bound && ptr < ts->m_data + s->stop_idx) { - records.emplace_back(*ptr); + if (ptr->is_tombstone()) --tot; + else if (!ptr->is_deleted()) ++tot; + //records.emplace_back(*ptr); ptr++; } - return records; + return {Wrapped<R>{0, {tot, 0}}}; + //return records; } static std::vector<Wrapped<R>> buffer_query(MutableBuffer<R> *buffer, void *state, void *parms) { + size_t tot = 0; auto p = (ts_range_query_parms<R> *) parms; auto s = (TrieSplineBufferState<R> *) state; - std::vector<Wrapped<R>> records; + //std::vector<Wrapped<R>> records; for (size_t i=0; i<s->cutoff; i++) { auto rec = buffer->get_data() + i; if (rec->rec.key >= p->lower_bound && rec->rec.key <= p->upper_bound) { - records.emplace_back(*rec); + if (rec->is_tombstone()) --tot; + else if (!rec->is_deleted()) ++tot; + //records.emplace_back(*rec); } } - - return records; + return {Wrapped<R>{0, {tot, 0}}}; + //return records; } static std::vector<R> merge(std::vector<std::vector<Wrapped<R>>> &results, void *parms) { - std::vector<Cursor<Wrapped<R>>> cursors; +/* + std::vector<Cursor<Wrapped<R>>> cursors; cursors.reserve(results.size()); PriorityQueue<Wrapped<R>> pq(results.size()); @@ -417,8 +425,13 @@ public: } } - return output; + return output;*/ + + size_t tot = 0; + for (auto& result: results) + if (result.size() > 0) tot += result[0].rec.key; + return {{tot, 0}}; } static void delete_query_state(void *state) { |