From 6fd50506d2e50d2faf2478a2883a2ef1b4840a78 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 17 May 2023 16:00:20 -0400 Subject: Started implementing shard interface (not finished yet) --- include/shard/WIRS.h | 53 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'include/shard/WIRS.h') diff --git a/include/shard/WIRS.h b/include/shard/WIRS.h index 2572caf..9f37396 100644 --- a/include/shard/WIRS.h +++ b/include/shard/WIRS.h @@ -25,6 +25,7 @@ namespace de { thread_local size_t wirs_cancelations = 0; + template class WIRS { private: @@ -53,6 +54,11 @@ private: }; public: + struct wirs_query_parms { + K lower_bound; + K upper_bound; + }; + WIRS(MutableBuffer* buffer, BloomFilter* bf) : m_reccnt(0), m_tombstone_cnt(0), m_deleted_cnt(0), m_total_weight(0), m_rejection_cnt(0), m_ts_check_cnt(0), m_root(nullptr) { @@ -178,14 +184,6 @@ public: return false; } - void free_tree(struct wirs_node* node) { - if (node) { - delete node->alias; - free_tree(node->left); - free_tree(node->right); - delete node; - } - } R* sorted_output() const { return m_data; @@ -206,8 +204,10 @@ public: // low - high -> decompose to a set of nodes. // Build Alias across the decomposed nodes. - WIRSState* get_sample_shard_state(const K& lower_key, const K& upper_key) { + WIRSState* get_query_state(void *query_parameters) { auto res = new WIRSState(); + K lower_key = ((wirs_query_parms *) query_parameters)->lower_bound; + K upper_key = ((wirs_query_parms *) query_parameters)->upper_bound; // Simulate a stack to unfold recursion. double tot_weight = 0.0; @@ -236,7 +236,7 @@ public: return res; } - static void delete_state(void *state) { + static void delete_query_state(void *state) { WIRSState *s = (WIRSState *) state; delete s; } @@ -293,26 +293,6 @@ public: return min; } - /* - bool check_delete(K key, V val) { - size_t idx = get_lower_bound(key); - if (idx >= m_reccnt) { - return false; - } - - auto ptr = m_data + get_lower_bound(key); - - while (ptr < m_data + m_reccnt && *ptr < R {key, val}) { - ptr ++; - } - - bool result = (m_tagging) ? ptr->is_deleted() - : *ptr == R {key, val} && ptr->is_tombstone(); - m_rejection_cnt += result; - return result; - } - */ - bool check_tombstone(const R& rec) { m_ts_check_cnt++; size_t idx = get_lower_bound(rec.key); @@ -332,12 +312,10 @@ public: return result; } - - size_t get_memory_utilization() { + size_t get_memory_usage() { return 0; } - size_t get_rejection_count() { return m_rejection_cnt; } @@ -418,6 +396,15 @@ private: m_root = construct_wirs_node(weights, 0, n_groups-1); } + void free_tree(struct wirs_node* node) { + if (node) { + delete node->alias; + free_tree(node->left); + free_tree(node->right); + delete node; + } + } + R* m_data; std::vector m_alias; wirs_node* m_root; -- cgit v1.2.3