From 05642ae192f50e7a40dc198451545f03f6b4d79a Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Tue, 13 Jun 2023 15:04:14 -0400 Subject: TrieSpline: fixed error in min/max key determination An elif was used when the conditions were _not_ supposed to be mutually exclusive, resulting in the wrong minimum key value being used in some cases. --- include/shard/TrieSpline.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/shard/TrieSpline.h b/include/shard/TrieSpline.h index 432614c..0cb0180 100644 --- a/include/shard/TrieSpline.h +++ b/include/shard/TrieSpline.h @@ -134,6 +134,12 @@ public: size_t attemp_reccnt = 0; size_t tombstone_count = 0; + + // initialize m_max_key and m_min_key using the values from the + // first shard. These will later be updated when building + // the initial priority queue to their true values. + m_max_key = shards[0]->m_max_key; + m_min_key = shards[0]->m_min_key; for (size_t i = 0; i < len; ++i) { if (shards[i]) { @@ -143,12 +149,11 @@ public: tombstone_count += shards[i]->get_tombstone_count(); pq.push(cursors[i].ptr, i); - if (i == 0) { - m_max_key = shards[i]->m_max_key; - m_min_key = shards[i]->m_min_key; - } else if (shards[i]->m_max_key > m_max_key) { + if (shards[i]->m_max_key > m_max_key) { m_max_key = shards[i]->m_max_key; - } else if (shards[i]->m_min_key < m_min_key) { + } + + if (shards[i]->m_min_key < m_min_key) { m_min_key = shards[i]->m_min_key; } } else { -- cgit v1.2.3