From 349cfd5090f586b7ec189b72c00786522199fe34 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 1 May 2024 16:03:19 -0400 Subject: TS BSM Adjustments --- benchmarks/include/triespline_bsm.h | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'benchmarks/include/triespline_bsm.h') diff --git a/benchmarks/include/triespline_bsm.h b/benchmarks/include/triespline_bsm.h index dfddc43..eaf1079 100644 --- a/benchmarks/include/triespline_bsm.h +++ b/benchmarks/include/triespline_bsm.h @@ -18,11 +18,19 @@ public: public: static BSMTrieSpline *build(std::vector &records) { + if (records.size() == 0) { + return nullptr; + } + std::sort(records.begin(), records.end()); return new BSMTrieSpline(records); } static BSMTrieSpline *build_presorted(std::vector &records) { + if (records.size() == 0) { + return nullptr; + } + return new BSMTrieSpline(records); } @@ -44,8 +52,9 @@ public: size_t idx = lower_bound(parms->lower_bound); size_t cnt = 0; - while (idx < m_data.size() && m_data[idx].first < parms->upper_bound) { + while (idx < m_data.size() && m_data[idx].first <= parms->upper_bound) { cnt++; + idx++; } rs.push_back({cnt, 0}); @@ -54,6 +63,10 @@ public: } std::vector query_merge(std::vector &rsa, std::vector &rsb, void *parms) { + /* initialize rsa on the first merge */ + if (rsa.size() == 0) { + rsa.push_back({0, 0}); + } rsa[0].first += rsb[0].first; return std::move(rsa); } @@ -75,6 +88,10 @@ private: m_min_key = m_data[0].first; m_max_key = m_data[m_data.size() - 1].first; + if (m_data.size() < 50) { + return; + } + auto bldr = ts::Builder(m_min_key, m_max_key, E); for (size_t i=0; i= key) { + return i; + } } + + return m_data.size(); } auto bound = m_ts.GetSearchBound(key); -- cgit v1.2.3