diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-09 12:40:26 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-05-09 12:40:26 -0400 |
| commit | 963df5b0dcccc686dff9eadee0de4c5d95db84db (patch) | |
| tree | 6b17a76d22b547411483d913a0e4fdb7f0e853a8 /include/shard/WIRS.h | |
| parent | 3e5df1ab4f581c795b7d3e1f1ba385efe47d6f15 (diff) | |
| download | dynamic-extension-963df5b0dcccc686dff9eadee0de4c5d95db84db.tar.gz | |
Initial port of DynamicExtension framework
Diffstat (limited to 'include/shard/WIRS.h')
| -rw-r--r-- | include/shard/WIRS.h | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/include/shard/WIRS.h b/include/shard/WIRS.h index 5d6baeb..d2f728f 100644 --- a/include/shard/WIRS.h +++ b/include/shard/WIRS.h @@ -22,14 +22,9 @@ namespace de { -struct sample_state; -template <typename K, typename V, typename W> -bool check_deleted(Record<K, V, W>* record, sample_state *state); extern thread_local size_t bounds_rejections; extern thread_local size_t tombstone_rejections; - - thread_local size_t m_wirsrun_cancelations = 0; template <typename K, typename V, typename W> @@ -211,8 +206,6 @@ public: // Build Alias across the decomposed nodes. WIRSState* get_sample_run_state(const K& lower_key, const K& upper_key) { WIRSState* res = new WIRSState(); - //std::vector<struct wirs_node*> nodes; - //double tot_weight = decompose_node(m_root, lower_key, upper_key, res->nodes); // Simulate a stack to unfold recursion. double tot_weight = 0.0; @@ -242,10 +235,15 @@ public: return res; } + static void delete_state(void *state) { + auto s = (WIRSState *) state; + delete s; + } + // returns the number of records sampled // NOTE: This operation returns records strictly between the lower and upper bounds, not // including them. - size_t get_samples(WIRSState* run_state, Record<K, V, W> *sample_set, const K& lower_key, const K& upper_key, size_t sample_sz, sample_state *state, gsl_rng *rng) { + size_t get_samples(WIRSState* run_state, std::vector<Record<K, V, W>> &result_set, const K& lower_key, const K& upper_key, size_t sample_sz, gsl_rng *rng) { if (sample_sz == 0) { return 0; } @@ -263,18 +261,14 @@ public: size_t rec_offset = fat_point * m_group_size + m_alias[fat_point]->get(rng); auto record = m_data + rec_offset; + // bounds rejection if (lower_key > record->key || upper_key < record->key) { - // bounds rejection bounds_rejections++; continue; - } else if (record->is_tombstone() || (state && check_deleted(record, state))) { - // tombstone/delete rejection - tombstone_rejections++; - continue; - } + } - sample_set[cnt++] = *record; - + result_set.emplace_back(*record); + cnt++; } while (attempts < sample_sz); return cnt; |