From 3672a26c78d6dcc2f3a9def3cbf26dcfa7b9e156 Mon Sep 17 00:00:00 2001 From: howsohazard <143410553+howsohazard@users.noreply.github.com> Date: Wed, 29 May 2024 17:26:33 -0400 Subject: [PATCH] 20420: Fixes bug where SDM caches would not always be properly cleared between queries (#142) --- src/Amalgam/GeneralizedDistance.h | 12 ++++++++++++ src/Amalgam/SeparableBoxFilterDataStore.cpp | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Amalgam/GeneralizedDistance.h b/src/Amalgam/GeneralizedDistance.h index f5ac488d..9a49ddff 100644 --- a/src/Amalgam/GeneralizedDistance.h +++ b/src/Amalgam/GeneralizedDistance.h @@ -1364,6 +1364,18 @@ class RepeatedGeneralizedDistanceEvaluator internedNumberIndexToNumberValue(nullptr) { } + //clears all the feature data + void Clear() + { + effectiveFeatureType = EFDT_CONTINUOUS_NUMERIC; + precomputedRemainingIdenticalDistanceTerm = 0.0; + internedNumberIndexToNumberValue = nullptr; + internedDistanceTerms.clear(); + nominalStringDistanceTerms.clear(); + nominalNumberDistanceTerms.clear(); + precomputedNominalDistanceTermsHighAccuracy = false; + } + //sets the value for a precomputed distance term that will apply to the rest of the distance //evaluations and changes the feature type appropriately inline void SetPrecomputedRemainingIdenticalDistanceTerm(double dist_term) diff --git a/src/Amalgam/SeparableBoxFilterDataStore.cpp b/src/Amalgam/SeparableBoxFilterDataStore.cpp index 0f3bd654..09d123f7 100644 --- a/src/Amalgam/SeparableBoxFilterDataStore.cpp +++ b/src/Amalgam/SeparableBoxFilterDataStore.cpp @@ -1440,8 +1440,7 @@ void SeparableBoxFilterDataStore::PopulateTargetValueAndLabelIndex(RepeatedGener auto &feature_data = r_dist_eval.featureData[query_feature_index]; auto &effective_feature_type = r_dist_eval.featureData[query_feature_index].effectiveFeatureType; - feature_data.internedNumberIndexToNumberValue = nullptr; - feature_data.internedDistanceTerms.clear(); + feature_data.Clear(); if(feature_attribs.IsFeatureNominal() || feature_type == GeneralizedDistanceEvaluator::FDT_CONTINUOUS_STRING