From 2aa6d6708034b2413640fb201adab20289e616aa Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Fri, 13 Mar 2026 10:10:40 +1300 Subject: [PATCH 01/20] [ML] Fix compiler warnings across the codebase Reduce Clang warnings from ~2500 to 86 (all remaining are -Wunsafe-buffer-usage which require a std::span migration). Compiler flag suppressions (clang.cmake): - -Wno-switch-default: conflicts with the more useful -Wswitch-enum - -Wno-nrvo: purely informational C++23 diagnostic - -Wno-missing-noreturn: remaining cases are lambdas where [[noreturn]] cannot be applied pre-C++23 Code fixes across 59 files: - Remove 37 unused const variables (dead code from state serialisation refactors) - Remove 2 unused functions and 2 unused-but-set variables - Fix 9 shadow warnings by renaming inner variables - Fix 8 implicit int-to-float conversions with static_cast - Fix 2 tautological-compare logic bugs where the condition !(p >= 0.0 || p <= 1.0) was always false - Remove 2 redundant default cases in exhaustive enum switches - Fix 1 pessimizing-move, 1 range-loop-bind-reference, 1 sign-compare, 1 shorten-64-to-32, 1 CTAD issue - Remove unnecessary virtual from method in final class - Add [[noreturn]] to named function throws() - Add missing newline at EOF Made-with: Cursor --- bin/pytorch_inference/Main.cc | 5 +- cmake/compiler/clang.cmake | 3 + include/maths/common/CBasicStatistics.h | 2 +- include/maths/common/CBootstrapClusterer.h | 9 +- include/model/CMetricModelFactory.h | 2 +- lib/api/CDataFrameAnalysisInstrumentation.cc | 3 - lib/api/CDetectionRulesJsonParser.cc | 1 - lib/api/CFieldDataCategorizer.cc | 6 +- lib/api/CForecastRunner.cc | 2 +- lib/api/CModelSizeStatsJsonWriter.cc | 1 - lib/api/CSingleFieldDataCategorizer.cc | 12 +- lib/api/unittest/CAnomalyJobTest.cc | 12 +- .../CDataFrameAnalyzerTrainingTest.cc | 2 +- .../unittest/CInferenceModelMetadataTest.cc | 2 +- lib/api/unittest/CTestAnomalyJob.cc | 2 +- lib/core/CJsonStateRestoreTraverser.cc | 3 - lib/core/CStateMachine.cc | 5 - lib/core/unittest/CConcurrencyTest.cc | 2 +- lib/maths/analytics/CBoostedTreeFactory.cc | 1 - lib/maths/analytics/CBoostedTreeLoss.cc | 1 - .../analytics/unittest/CDataFrameUtilsTest.cc | 3 +- lib/maths/common/CCategoricalTools.cc | 4 +- lib/maths/common/CGammaRateConjugate.cc | 1 - .../common/CLogNormalMeanPrecConjugate.cc | 1 - lib/maths/common/CModel.cc | 1 - lib/maths/common/CMultimodalPrior.cc | 2 - lib/maths/common/CMultinomialConjugate.cc | 2 - .../common/CMultivariateConstantPrior.cc | 2 - lib/maths/common/CNaturalBreaksClassifier.cc | 1 - lib/maths/common/CNormalMeanPrecConjugate.cc | 1 - lib/maths/common/COneOfNPrior.cc | 2 - lib/maths/common/CPoissonMeanConjugate.cc | 1 - lib/maths/common/CPriorStateSerialiser.cc | 2 - lib/maths/common/CStatisticalTests.cc | 1 - lib/maths/common/CXMeansOnline1d.cc | 2 - .../CMultivariateNormalConjugateTest.cc | 135 ------------------ lib/maths/common/unittest/CToolsTest.cc | 3 +- lib/maths/time_series/CAdaptiveBucketing.cc | 1 - lib/maths/time_series/CCalendarComponent.cc | 1 - .../CCalendarComponentAdaptiveBucketing.cc | 1 - lib/maths/time_series/CCalendarCyclicTest.cc | 4 +- .../time_series/CDecompositionComponent.cc | 2 - lib/maths/time_series/CSeasonalComponent.cc | 1 - .../CSeasonalComponentAdaptiveBucketing.cc | 1 - .../time_series/CTimeSeriesDecomposition.cc | 2 - .../CTimeSeriesDecompositionDetail.cc | 6 +- ...CTimeSeriesDecompositionStateSerialiser.cc | 1 - .../unittest/CCalendarCyclicTestTest.cc | 3 +- lib/model/CAnnotatedProbability.cc | 1 - lib/model/CDataGatherer.cc | 2 - lib/model/CDetectorEqualizer.cc | 8 +- lib/model/CEventRateModel.cc | 2 +- lib/model/CMetricBucketGatherer.cc | 1 - lib/model/CResourceMonitor.cc | 1 - lib/model/CSearchKey.cc | 3 - lib/model/FunctionTypes.cc | 1 - lib/model/unittest/CModelMemoryTest.cc | 2 - .../unittest/CTokenListDataCategorizerTest.cc | 4 +- lib/model/unittest/ModelTestHelpers.h | 4 +- 59 files changed, 56 insertions(+), 236 deletions(-) diff --git a/bin/pytorch_inference/Main.cc b/bin/pytorch_inference/Main.cc index 00adee1dfc..76177ccee4 100644 --- a/bin/pytorch_inference/Main.cc +++ b/bin/pytorch_inference/Main.cc @@ -48,7 +48,8 @@ const std::unordered_set FORBIDDEN_OPERATIONS = {"aten::from_f void verifySafeModel(const torch::jit::script::Module& module_) { try { const auto method = module_.get_method("forward"); - for (const auto graph = method.graph(); const auto& node : graph->nodes()) { + const auto& graph = method.graph(); + for (const auto* node : graph->nodes()) { if (const std::string opName = node->kind().toQualString(); FORBIDDEN_OPERATIONS.contains(opName)) { HANDLE_FATAL(<< "Loading the inference process failed because it contains forbidden operation: " @@ -282,7 +283,7 @@ int main(int argc, char** argv) { // allocations rather than per allocation. But macOS is not supported for // production, but just as a convenience for developers. So the most // important thing is that the threading works as intended on Linux. - at::set_num_threads(threadSettings.numThreadsPerAllocation()); + at::set_num_threads(static_cast(threadSettings.numThreadsPerAllocation())); // This is not used as we don't call at::launch anywhere. // Setting it to 1 to ensure there is no thread pool sitting around. diff --git a/cmake/compiler/clang.cmake b/cmake/compiler/clang.cmake index cc4042dbc7..7dd8adf360 100644 --- a/cmake/compiler/clang.cmake +++ b/cmake/compiler/clang.cmake @@ -32,6 +32,9 @@ list(APPEND ML_C_FLAGS "-Wno-padded" "-Wno-poison-system-directories" "-Wno-sign-conversion" + "-Wno-missing-noreturn" + "-Wno-nrvo" + "-Wno-switch-default" "-Wno-unknown-warning-option" "-Wno-unreachable-code" "-Wno-used-but-marked-unused" diff --git a/include/maths/common/CBasicStatistics.h b/include/maths/common/CBasicStatistics.h index 260c10e15d..5e89f41ecc 100644 --- a/include/maths/common/CBasicStatistics.h +++ b/include/maths/common/CBasicStatistics.h @@ -1420,7 +1420,7 @@ struct SCentralMomentsCustomAdd { static inline void add(const U& x, typename SCoordinate::Type n, CBasicStatistics::SSampleCentralMoments& moments) { - moments.add(x, n, 0); + moments.add(x, static_cast(n), 0); } }; } diff --git a/include/maths/common/CBootstrapClusterer.h b/include/maths/common/CBootstrapClusterer.h index 1577d2f783..6618cc5ad6 100644 --- a/include/maths/common/CBootstrapClusterer.h +++ b/include/maths/common/CBootstrapClusterer.h @@ -677,8 +677,6 @@ class CBootstrapClusterer { this->visit(next, graph, parities, state); double lowestCost = state.cost(); - double bestCut = state.s_Cut; - std::size_t bestA = state.s_A; TBoolVec best = parities; while (state.s_A + 1 < V) { @@ -725,8 +723,6 @@ class CBootstrapClusterer { double cutCost = state.cost(); if (cutCost < lowestCost) { lowestCost = cutCost; - bestCut = state.s_Cut; - bestA = state.s_A; best = parities; } } @@ -734,7 +730,10 @@ class CBootstrapClusterer { cost = lowestCost; parities.swap(best); - LOG_TRACE(<< "Best cut = " << bestCut << ", |A| = " << bestA << ", |B| = " << V - bestA + LOG_TRACE(<< "Best cut |A| = " + << static_cast(std::count(parities.begin(), parities.end(), true)) + << ", |B| = " + << V - static_cast(std::count(parities.begin(), parities.end(), true)) << ", cost = " << cost << ", threshold = " << threshold); return cost < threshold; diff --git a/include/model/CMetricModelFactory.h b/include/model/CMetricModelFactory.h index c14f7aca66..8cd4687bf8 100644 --- a/include/model/CMetricModelFactory.h +++ b/include/model/CMetricModelFactory.h @@ -135,7 +135,7 @@ class MODEL_EXPORT CMetricModelFactory final : public CModelFactory { void features(const TFeatureVec& features) override; //! Set the modeled bucket length. - virtual void bucketLength(core_t::TTime bucketLength); + void bucketLength(core_t::TTime bucketLength); //@} //! Get the minimum seasonal variance scale diff --git a/lib/api/CDataFrameAnalysisInstrumentation.cc b/lib/api/CDataFrameAnalysisInstrumentation.cc index 06725b33ca..717e478c77 100644 --- a/lib/api/CDataFrameAnalysisInstrumentation.cc +++ b/lib/api/CDataFrameAnalysisInstrumentation.cc @@ -56,14 +56,11 @@ const std::string MEMORY_TYPE_TAG{"analytics_memory_usage"}; const std::string OUTLIER_DETECTION_STATS{"outlier_detection_stats"}; const std::string PARAMETERS_TAG{"parameters"}; const std::string PEAK_MEMORY_USAGE_TAG{"peak_usage_bytes"}; -const std::string PROGRESS_TAG{"progress"}; const std::string REGRESSION_STATS_TAG{"regression_stats"}; -const std::string STEP_TAG{"step"}; const std::string TIMESTAMP_TAG{"timestamp"}; const std::string TIMING_ELAPSED_TIME_TAG{"elapsed_time"}; const std::string TIMING_ITERATION_TIME_TAG{"iteration_time"}; const std::string TIMING_STATS_TAG{"timing_stats"}; -const std::string TYPE_TAG{"type"}; const std::string VALIDATION_FOLD_TAG{"fold"}; const std::string VALIDATION_FOLD_VALUES_TAG{"fold_values"}; const std::string VALIDATION_LOSS_TAG{"validation_loss"}; diff --git a/lib/api/CDetectionRulesJsonParser.cc b/lib/api/CDetectionRulesJsonParser.cc index 3171c9e3b4..f2bb7797a3 100644 --- a/lib/api/CDetectionRulesJsonParser.cc +++ b/lib/api/CDetectionRulesJsonParser.cc @@ -22,7 +22,6 @@ namespace { const std::string ACTIONS("actions"); const std::string ACTUAL("actual"); const std::string APPLIES_TO("applies_to"); -const std::string CONDITION("condition"); const std::string CONDITIONS("conditions"); const std::string DIFF_FROM_TYPICAL("diff_from_typical"); const std::string EXCLUDE("exclude"); diff --git a/lib/api/CFieldDataCategorizer.cc b/lib/api/CFieldDataCategorizer.cc index 6badb81c48..77d8cc6e12 100644 --- a/lib/api/CFieldDataCategorizer.cc +++ b/lib/api/CFieldDataCategorizer.cc @@ -603,11 +603,11 @@ bool CFieldDataCategorizer::periodicPersistStateInBackground() { // Do NOT pass the captures by reference - they // MUST be copied for thread safety if (m_PersistenceManager->addPersistFunc([ - this, partitionFieldValues = std::move(partitionFieldValues), - dataCategorizerPersistFuncs = std::move(dataCategorizerPersistFuncs), + this, partitionFieldValuesInner = std::move(partitionFieldValues), + dataCategorizerPersistFuncsInner = std::move(dataCategorizerPersistFuncs), categorizerAllocationFailures = m_CategorizerAllocationFailures ](core::CDataAdder & persister) { - return this->doPersistState(partitionFieldValues, dataCategorizerPersistFuncs, + return this->doPersistState(partitionFieldValuesInner, dataCategorizerPersistFuncsInner, categorizerAllocationFailures, persister); }) == false) { LOG_ERROR(<< "Failed to add categorizer background persistence function"); diff --git a/lib/api/CForecastRunner.cc b/lib/api/CForecastRunner.cc index c6c4fcf465..ea639832fb 100644 --- a/lib/api/CForecastRunner.cc +++ b/lib/api/CForecastRunner.cc @@ -442,7 +442,7 @@ bool CForecastRunner::parseAndValidateForecastRequest(const std::string& control if (forecastJob.s_MaxForecastModelMemory != DEFAULT_MAX_FORECAST_MODEL_MEMORY && (forecastJob.s_MaxForecastModelMemory >= MAX_FORECAST_MODEL_PERSISTANCE_MEMORY || forecastJob.s_MaxForecastModelMemory >= - static_cast(jobBytesSizeLimit * 0.40))) { + static_cast(static_cast(jobBytesSizeLimit) * 0.40))) { errorFunction(forecastJob, ERROR_BAD_MODEL_MEMORY_LIMIT); return false; } diff --git a/lib/api/CModelSizeStatsJsonWriter.cc b/lib/api/CModelSizeStatsJsonWriter.cc index 68b5b80c88..1deb4deac4 100644 --- a/lib/api/CModelSizeStatsJsonWriter.cc +++ b/lib/api/CModelSizeStatsJsonWriter.cc @@ -25,7 +25,6 @@ const std::string JOB_ID{"job_id"}; const std::string MODEL_SIZE_STATS{"model_size_stats"}; const std::string MODEL_BYTES{"model_bytes"}; const std::string PEAK_MODEL_BYTES{"peak_model_bytes"}; -const std::string SYSTEM_MEMORY_BYTES{"system_memory_bytes"}; const std::string MAX_SYSTEM_MEMORY_BYTES{"max_system_memory_bytes"}; const std::string MODEL_BYTES_EXCEEDED{"model_bytes_exceeded"}; const std::string MODEL_BYTES_MEMORY_LIMIT{"model_bytes_memory_limit"}; diff --git a/lib/api/CSingleFieldDataCategorizer.cc b/lib/api/CSingleFieldDataCategorizer.cc index c993a8d78d..a54e2c232f 100644 --- a/lib/api/CSingleFieldDataCategorizer.cc +++ b/lib/api/CSingleFieldDataCategorizer.cc @@ -104,10 +104,10 @@ CSingleFieldDataCategorizer::makeForegroundPersistFunc() const { model::CDataCategorizer::TPersistFunc categorizerPersistFunc{ m_DataCategorizer->makeForegroundPersistFunc()}; - return [ categorizerPersistFunc = std::move(categorizerPersistFunc), + return [ categorizerPersistFuncInner = std::move(categorizerPersistFunc), this ](core::CStatePersistInserter & inserter) { CSingleFieldDataCategorizer::acceptPersistInserter( - categorizerPersistFunc, m_DataCategorizer->examplesCollector(), + categorizerPersistFuncInner, m_DataCategorizer->examplesCollector(), *m_CategoryIdMapper, inserter); }; } @@ -126,12 +126,12 @@ CSingleFieldDataCategorizer::makeBackgroundPersistFunc() const { // function must be able to operate in a different thread on a snapshot of // the data at the time it was created. return [ - categorizerPersistFunc = std::move(categorizerPersistFunc), - examplesCollector = std::move(examplesCollector), - categoryIdMapperClone = std::move(categoryIdMapperClone) + categorizerPersistFuncInner = std::move(categorizerPersistFunc), + examplesCollectorInner = std::move(examplesCollector), + categoryIdMapperCloneInner = std::move(categoryIdMapperClone) ](core::CStatePersistInserter & inserter) { CSingleFieldDataCategorizer::acceptPersistInserter( - categorizerPersistFunc, examplesCollector, *categoryIdMapperClone, inserter); + categorizerPersistFuncInner, examplesCollectorInner, *categoryIdMapperCloneInner, inserter); }; } diff --git a/lib/api/unittest/CAnomalyJobTest.cc b/lib/api/unittest/CAnomalyJobTest.cc index d5384327ef..d59e1af4e0 100644 --- a/lib/api/unittest/CAnomalyJobTest.cc +++ b/lib/api/unittest/CAnomalyJobTest.cc @@ -306,8 +306,8 @@ BOOST_AUTO_TEST_CASE(testOutputBucketResultsUntilGivenIncompleteInitialBucket) { "testfiles/testLogErrors.boost.log.ini")); // Start by creating a detector with non-trivial state - static const core_t::TTime BUCKET_SIZE{900}; - static const std::string JOB_ID{"pop_sum_bytes_by_status_over_clientip"}; + static const core_t::TTime testBucketSize{900}; + static const std::string testJobId{"pop_sum_bytes_by_status_over_clientip"}; // Open the input and output files std::ifstream inputStrm{inputFileName.c_str()}; @@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(testOutputBucketResultsUntilGivenIncompleteInitialBucket) { BOOST_TEST_REQUIRE(jobConfig.initFromFile(configFileName)); model::CAnomalyDetectorModelConfig modelConfig = - model::CAnomalyDetectorModelConfig::defaultConfig(BUCKET_SIZE, model_t::E_None, + model::CAnomalyDetectorModelConfig::defaultConfig(testBucketSize, model_t::E_None, "", 0, false); core::CJsonOutputStreamWrapper wrappedOutputStream{outputStrm}; @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(testOutputBucketResultsUntilGivenIncompleteInitialBucket) { std::string origSnapshotId; std::size_t numOrigDocs{0}; - CTestAnomalyJob origJob{JOB_ID, + CTestAnomalyJob origJob{testJobId, limits, jobConfig, modelConfig, @@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(testOutputBucketResultsUntilGivenIncompleteInitialBucket) { std::size_t numRestoredDocs{0}; CTestAnomalyJob restoredJob{ - JOB_ID, + testJobId, limits, jobConfig, modelConfig, @@ -879,7 +879,7 @@ BOOST_AUTO_TEST_CASE(testConfigUpdate) { auto generateRandomAlpha = [](int strLen) { std::random_device rd; std::mt19937 gen(rd()); - std::uniform_int_distribution dis(0, 25); + std::uniform_int_distribution dis(0, 25); std::string str; for (int i = 0; i < strLen; ++i) { diff --git a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc index 1224055d75..07e84ca65e 100644 --- a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc +++ b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc @@ -2233,7 +2233,7 @@ BOOST_AUTO_TEST_CASE(testProgressMonitoringFromRestart) { analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "", "$"}); TStrVec persistedStates{ - splitOnNull(std::stringstream{std::move(persistenceStream->str())})}; + splitOnNull(std::stringstream{persistenceStream->str()})}; LOG_DEBUG(<< "# states = " << persistedStates.size()); diff --git a/lib/api/unittest/CInferenceModelMetadataTest.cc b/lib/api/unittest/CInferenceModelMetadataTest.cc index c0aa6ee652..d7bbddcf89 100644 --- a/lib/api/unittest/CInferenceModelMetadataTest.cc +++ b/lib/api/unittest/CInferenceModelMetadataTest.cc @@ -306,7 +306,7 @@ BOOST_AUTO_TEST_CASE(testDataSummarization) { // check correct number of rows up to a rounding error BOOST_REQUIRE_CLOSE_ABSOLUTE(static_cast(dataSummarizationNumRows), - numRows * summarizationFraction, 1.0); + static_cast(numRows) * summarizationFraction, 1.0); } BOOST_AUTO_TEST_SUITE_END() diff --git a/lib/api/unittest/CTestAnomalyJob.cc b/lib/api/unittest/CTestAnomalyJob.cc index 5a3f678932..6e10bf0d7d 100644 --- a/lib/api/unittest/CTestAnomalyJob.cc +++ b/lib/api/unittest/CTestAnomalyJob.cc @@ -71,4 +71,4 @@ ml::api::CAnomalyJobConfig CTestAnomalyJob::makeJobConfig(const std::string& det ml::api::CAnomalyJobConfig jobConfig; jobConfig.analysisConfig().parseDetectorsConfig(obj); return jobConfig; -} \ No newline at end of file +} diff --git a/lib/core/CJsonStateRestoreTraverser.cc b/lib/core/CJsonStateRestoreTraverser.cc index c28ebfde68..333af1f56b 100644 --- a/lib/core/CJsonStateRestoreTraverser.cc +++ b/lib/core/CJsonStateRestoreTraverser.cc @@ -360,9 +360,6 @@ bool CJsonStateRestoreTraverser::start() { case SBoostJsonHandler::E_TokenStringPart: tokenTypeName = "string_part"; break; - default: - tokenTypeName = "unknown"; - break; } LOG_ERROR(<< "JSON state must be object at root. Found token type: " << tokenTypeName diff --git a/lib/core/CStateMachine.cc b/lib/core/CStateMachine.cc index 3d79b324d6..725c6b0285 100644 --- a/lib/core/CStateMachine.cc +++ b/lib/core/CStateMachine.cc @@ -31,11 +31,6 @@ namespace { //const std::string MACHINE_TAG("a"); No longer used const core::TPersistenceTag STATE_TAG("b", "state"); -// CStateMachine::SMachine -const std::string ALPHABET_TAG("a"); -const std::string STATES_TAG("b"); -const std::string TRANSITION_FUNCTION_TAG("c"); - std::size_t BAD_MACHINE = std::numeric_limits::max(); CFastMutex mutex; } diff --git a/lib/core/unittest/CConcurrencyTest.cc b/lib/core/unittest/CConcurrencyTest.cc index a6893f32fb..fcb9159192 100644 --- a/lib/core/unittest/CConcurrencyTest.cc +++ b/lib/core/unittest/CConcurrencyTest.cc @@ -30,7 +30,7 @@ namespace { using TIntVec = std::vector; using TIntVecVec = std::vector; -double throws() { +[[noreturn]] double throws() { throw std::runtime_error("don't run me"); }; diff --git a/lib/maths/analytics/CBoostedTreeFactory.cc b/lib/maths/analytics/CBoostedTreeFactory.cc index 65f0ef53b6..ca29d1111c 100644 --- a/lib/maths/analytics/CBoostedTreeFactory.cc +++ b/lib/maths/analytics/CBoostedTreeFactory.cc @@ -1903,7 +1903,6 @@ const std::string FACTORY_TAG{"factory"}; const std::string GAIN_PER_NODE_1ST_PERCENTILE_TAG{"gain_per_node_1st_percentile"}; const std::string GAIN_PER_NODE_50TH_PERCENTILE_TAG{"gain_per_node_50th_percentile"}; const std::string GAIN_PER_NODE_90TH_PERCENTILE_TAG{"gain_per_node_90th_percentile"}; -const std::string HYPERPARAMETERS_LOSSES_TAG{"hyperparameters_losses"}; const std::string INITIALIZATION_CHECKPOINT_TAG{"initialization_checkpoint"}; const std::string LOSS_GAP_TAG{"loss_gap"}; const std::string NUMBER_TREES_TAG{"number_trees"}; diff --git a/lib/maths/analytics/CBoostedTreeLoss.cc b/lib/maths/analytics/CBoostedTreeLoss.cc index e3a3835762..fe486d263b 100644 --- a/lib/maths/analytics/CBoostedTreeLoss.cc +++ b/lib/maths/analytics/CBoostedTreeLoss.cc @@ -57,7 +57,6 @@ const std::size_t HUBER_OPTIMIZATION_ITERATIONS{15}; const std::string NUMBER_CLASSES_TAG{"number_classes"}; const std::string OFFSET_TAG{"offset"}; const std::string DELTA_TAG{"delta"}; -const std::string NAME_TAG{"name"}; double logOneMinusLogistic(double logOdds) { // For large x logistic(x) = 1 - e^(-x) + O(e^(-2x)) diff --git a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc index d2b036bc5a..8f838bb39f 100644 --- a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc +++ b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc @@ -846,7 +846,8 @@ BOOST_AUTO_TEST_CASE(testDistributionPreservingSamplingRowMasks) { BOOST_REQUIRE_EQUAL(actualCategoryCounts.size(), expectedCategoryCounts.size()); for (std::size_t i = 0; i < expectedCategoryCounts.size(); ++i) { - BOOST_REQUIRE_EQUAL(actualCategoryCounts[i], expectedCategoryCounts[i]); + BOOST_REQUIRE_EQUAL(actualCategoryCounts[i], + expectedCategoryCounts[static_cast(i)]); } } diff --git a/lib/maths/common/CCategoricalTools.cc b/lib/maths/common/CCategoricalTools.cc index f90d9c57ed..c59c7bfb74 100644 --- a/lib/maths/common/CCategoricalTools.cc +++ b/lib/maths/common/CCategoricalTools.cc @@ -41,7 +41,7 @@ logBinomialProbabilityFastLowerBound(std::size_t n, double p, std::size_t m, dou result = 0.0; - if (!(p >= 0.0 || p <= 1.0)) { + if (!(p >= 0.0 && p <= 1.0)) { LOG_ERROR(<< "Bad probability: " << p); return maths_t::E_FpFailed; } @@ -588,7 +588,7 @@ CCategoricalTools::logMultinomialProbability(const TDoubleVec& probabilities, double ni_ = static_cast(ni[i]); if (ni_ > 0.0) { double pi_ = probabilities[i]; - if (!(pi_ >= 0.0 || pi_ <= 1.0)) { + if (!(pi_ >= 0.0 && pi_ <= 1.0)) { LOG_ERROR(<< "Bad probability: " << pi_); return maths_t::E_FpFailed; } diff --git a/lib/maths/common/CGammaRateConjugate.cc b/lib/maths/common/CGammaRateConjugate.cc index f3a1045d6b..bc27ddf7bd 100644 --- a/lib/maths/common/CGammaRateConjugate.cc +++ b/lib/maths/common/CGammaRateConjugate.cc @@ -724,7 +724,6 @@ const core::TPersistenceTag DECAY_RATE_TAG("j", "decay_rate"); const std::string MEAN_TAG("mean"); const std::string STANDARD_DEVIATION_TAG("standard_deviation"); const std::string EMPTY_STRING; -const std::string UNKNOWN_VALUE_STRING(""); } CGammaRateConjugate::CGammaRateConjugate(maths_t::EDataType dataType, diff --git a/lib/maths/common/CLogNormalMeanPrecConjugate.cc b/lib/maths/common/CLogNormalMeanPrecConjugate.cc index e49a4cd931..980c424404 100644 --- a/lib/maths/common/CLogNormalMeanPrecConjugate.cc +++ b/lib/maths/common/CLogNormalMeanPrecConjugate.cc @@ -630,7 +630,6 @@ const core::TPersistenceTag NUMBER_SAMPLES_TAG("f", "number_samples"); const core::TPersistenceTag DECAY_RATE_TAG("i", "decay_rate"); const std::string MEAN_TAG("mean"); const std::string STANDARD_DEVIATION_TAG("standard_deviation"); -const std::string EMPTY_STRING; } CLogNormalMeanPrecConjugate::CLogNormalMeanPrecConjugate(maths_t::EDataType dataType, diff --git a/lib/maths/common/CModel.cc b/lib/maths/common/CModel.cc index 7c23b5b677..12107c3aa1 100644 --- a/lib/maths/common/CModel.cc +++ b/lib/maths/common/CModel.cc @@ -26,7 +26,6 @@ namespace maths { namespace common { namespace { -const std::string EMPTY_STRING; const double EFFECTIVE_COUNT[]{1.0, 0.8, 0.7, 0.65, 0.6, 0.57, 0.54, 0.52, 0.51}; diff --git a/lib/maths/common/CMultimodalPrior.cc b/lib/maths/common/CMultimodalPrior.cc index eb7d9968a9..86635cdc7d 100644 --- a/lib/maths/common/CMultimodalPrior.cc +++ b/lib/maths/common/CMultimodalPrior.cc @@ -131,8 +131,6 @@ const core::TPersistenceTag SEED_PRIOR_TAG("b", "seed_prior"); const core::TPersistenceTag MODE_TAG("c", "mode"); const core::TPersistenceTag NUMBER_SAMPLES_TAG("d", "number_samples"); const core::TPersistenceTag DECAY_RATE_TAG("g", "decay_rate"); - -const std::string EMPTY_STRING; } //////// CMultimodalPrior Implementation //////// diff --git a/lib/maths/common/CMultinomialConjugate.cc b/lib/maths/common/CMultinomialConjugate.cc index f2e96bafaf..fc4e3f4576 100644 --- a/lib/maths/common/CMultinomialConjugate.cc +++ b/lib/maths/common/CMultinomialConjugate.cc @@ -248,8 +248,6 @@ const core::TPersistenceTag CONCENTRATION_TAG("c", "concentration"); const core::TPersistenceTag TOTAL_CONCENTRATION_TAG("d", "total_concentration"); const core::TPersistenceTag NUMBER_SAMPLES_TAG("e", "number_samples"); const core::TPersistenceTag DECAY_RATE_TAG("h", "decay_rate"); - -const std::string EMPTY_STRING; } CMultinomialConjugate::CMultinomialConjugate() diff --git a/lib/maths/common/CMultivariateConstantPrior.cc b/lib/maths/common/CMultivariateConstantPrior.cc index 619483ae52..d55a530734 100644 --- a/lib/maths/common/CMultivariateConstantPrior.cc +++ b/lib/maths/common/CMultivariateConstantPrior.cc @@ -56,8 +56,6 @@ void setConstant(std::size_t dimension, TDouble10Vec value, TOptionalDouble10Vec // We use short field names to reduce the state size const std::string CONSTANT_TAG("a"); - -const std::string EMPTY_STRING; } CMultivariateConstantPrior::CMultivariateConstantPrior(std::size_t dimension, diff --git a/lib/maths/common/CNaturalBreaksClassifier.cc b/lib/maths/common/CNaturalBreaksClassifier.cc index 443cbc3de8..f07a3eac3c 100644 --- a/lib/maths/common/CNaturalBreaksClassifier.cc +++ b/lib/maths/common/CNaturalBreaksClassifier.cc @@ -40,7 +40,6 @@ const core::TPersistenceTag SPACE_TAG("a", "space"); const core::TPersistenceTag CATEGORY_TAG("b", "category"); const core::TPersistenceTag POINTS_TAG("c", "points"); const core::TPersistenceTag DECAY_RATE_TAG("d", "decay_rate"); -const std::string EMPTY_STRING; const double ALMOST_ONE = 0.99999; } diff --git a/lib/maths/common/CNormalMeanPrecConjugate.cc b/lib/maths/common/CNormalMeanPrecConjugate.cc index e3fedb4d51..7c81d1112d 100644 --- a/lib/maths/common/CNormalMeanPrecConjugate.cc +++ b/lib/maths/common/CNormalMeanPrecConjugate.cc @@ -450,7 +450,6 @@ const core::TPersistenceTag NUMBER_SAMPLES_TAG("e", "number_samples"); const core::TPersistenceTag DECAY_RATE_TAG("h", "decay_rate"); const std::string MEAN_TAG("mean"); const std::string STANDARD_DEVIATION_TAG("standard_deviation"); -const std::string EMPTY_STRING; } CNormalMeanPrecConjugate::CNormalMeanPrecConjugate(maths_t::EDataType dataType, diff --git a/lib/maths/common/COneOfNPrior.cc b/lib/maths/common/COneOfNPrior.cc index b71e4a45e0..0383eaa483 100644 --- a/lib/maths/common/COneOfNPrior.cc +++ b/lib/maths/common/COneOfNPrior.cc @@ -77,8 +77,6 @@ const std::string DECAY_RATE_OLD_TAG("e"); const core::TPersistenceTag WEIGHT_TAG("a", "weight"); const core::TPersistenceTag PRIOR_TAG("b", "prior"); -const std::string EMPTY_STRING; - //! Persist state for a models by passing information to \p inserter. void modelAcceptPersistInserter(const CModelWeight& weight, const CPrior& prior, diff --git a/lib/maths/common/CPoissonMeanConjugate.cc b/lib/maths/common/CPoissonMeanConjugate.cc index 5caac8ad69..8b140cde14 100644 --- a/lib/maths/common/CPoissonMeanConjugate.cc +++ b/lib/maths/common/CPoissonMeanConjugate.cc @@ -169,7 +169,6 @@ const core::TPersistenceTag OFFSET_TAG("d", "offset"); const core::TPersistenceTag DECAY_RATE_TAG("g", "decay_rate"); const std::string MEAN_TAG("mean"); const std::string STANDARD_DEVIATION_TAG("standard_deviation"); -const std::string EMPTY_STRING; } CPoissonMeanConjugate::CPoissonMeanConjugate(double offset, double shape, double rate, double decayRate /*= 0.0*/) diff --git a/lib/maths/common/CPriorStateSerialiser.cc b/lib/maths/common/CPriorStateSerialiser.cc index 1608131468..34e5af5efb 100644 --- a/lib/maths/common/CPriorStateSerialiser.cc +++ b/lib/maths/common/CPriorStateSerialiser.cc @@ -48,8 +48,6 @@ const core::TPersistenceTag POISSON_TAG("f", "poisson"); const core::TPersistenceTag MULTINOMIAL_TAG("g", "multimonial"); const core::TPersistenceTag CONSTANT_TAG("h", "constant"); -const std::string EMPTY_STRING; - //! Implements restore for std::shared_ptr. template void doRestore(std::shared_ptr& ptr, core::CStateRestoreTraverser& traverser) { diff --git a/lib/maths/common/CStatisticalTests.cc b/lib/maths/common/CStatisticalTests.cc index 60d2352dc2..60d12539c6 100644 --- a/lib/maths/common/CStatisticalTests.cc +++ b/lib/maths/common/CStatisticalTests.cc @@ -65,7 +65,6 @@ double significance(double lambda) { const std::string SIZE_TAG("a"); const std::string T_TAG("b"); const std::string F_TAG("c"); -const std::string EMPTY_STRING; } double CStatisticalTests::leftTailFTest(double v0, double v1, double df0, double df1) { diff --git a/lib/maths/common/CXMeansOnline1d.cc b/lib/maths/common/CXMeansOnline1d.cc index bbfadf8dd1..908251d318 100644 --- a/lib/maths/common/CXMeansOnline1d.cc +++ b/lib/maths/common/CXMeansOnline1d.cc @@ -634,8 +634,6 @@ const core::TPersistenceTag HISTORY_LENGTH_TAG("k", "history_length"); const core::TPersistenceTag INDEX_TAG("a", "index"); const core::TPersistenceTag STRUCTURE_TAG("b", "structure"); const core::TPersistenceTag PRIOR_TAG("c", "prior"); - -const std::string EMPTY_STRING; } CAvailableModeDistributions::CAvailableModeDistributions(int value) diff --git a/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc b/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc index 37444a2cd1..5254f375b4 100644 --- a/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc +++ b/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc @@ -83,141 +83,6 @@ void gaussianSamples(test::CRandomNumbers& rng, LOG_DEBUG(<< "# samples = " << samples.size()); } -void calibrationExperiment() { - using TVector10 = maths::common::CVectorNx1; - using TMatrix10 = maths::common::CSymmetricMatrixNxN; - - double means[] = {10.0, 10.0, 20.0, 20.0, 30.0, - 20.0, 10.0, 40.0, 30.0, 20.0}; - double covariances[] = { - 10.0, 9.0, 10.0, -5.0, 1.0, 6.0, -8.0, 9.0, 4.0, 20.0, 8.0, - 3.0, 1.0, 12.0, 12.0, -4.0, 2.0, 1.0, 1.0, 4.0, 4.0, 5.0, - 1.0, 3.0, 8.0, 10.0, 3.0, 10.0, 9.0, 9.0, 5.0, 19.0, 11.0, - 3.0, 9.0, 25.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 20.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; - TVector10 mean(means, means + std::size(means)); - TMatrix10 covariance(covariances, covariances + std::size(covariances)); - - test::CRandomNumbers rng; - TDoubleVecVec samples_; - rng.generateMultivariateNormalSamples(mean.toVector(), - covariance.toVectors(), - 2000, samples_); - - TDouble10Vec1Vec samples; - samples.reserve(samples.size() + samples_.size()); - for (std::size_t j = 0; j < samples_.size(); ++j) { - samples.push_back(TDouble10Vec(samples_[j].begin(), samples_[j].end())); - } - - maths::common::CMultivariateNormalConjugate<2> filters[] = { - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior(maths_t::E_ContinuousData), - maths::common::CMultivariateNormalConjugate<2>::nonInformativePrior( - maths_t::E_ContinuousData)}; - std::size_t indices[][2] = {{0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, - {0, 6}, {0, 7}, {0, 8}, {0, 9}}; - - for (std::size_t i = 0; i < 200; ++i) { - for (std::size_t j = 0; j < std::size(filters); ++j) { - TDouble10Vec1Vec sample(1, TDouble10Vec(2)); - sample[0][0] = samples[i][indices[j][0]]; - sample[0][1] = samples[i][indices[j][1]]; - filters[j].addSamples( - sample, maths_t::CUnitWeights::singleUnit(2)); - } - } - - TDoubleVecVec p(std::size(filters)); - TDoubleVec mp; - TDoubleVec ep; - for (std::size_t i = 200; i < 2000; ++i) { - double mpi = 1.0; - maths::common::CProbabilityOfExtremeSample epi; - for (std::size_t j = 0; j < std::size(filters); ++j) { - TDouble10Vec1Vec sample(1, TDouble10Vec(2)); - sample[0][0] = samples[i][indices[j][0]]; - sample[0][1] = samples[i][indices[j][1]]; - double lb, ub; - maths::common::CMultivariatePrior::TTail10Vec tail; - filters[j].probabilityOfLessLikelySamples( - maths_t::E_TwoSided, sample, - maths_t::CUnitWeights::singleUnit(2), lb, ub, tail); - p[j].push_back((lb + ub) / 2.0); - mpi = std::min(mpi, (lb + ub) / 2.0); - epi.add((lb + ub) / 2.0, 0.5); - } - mp.push_back(mpi); - double pi; - epi.calculate(pi); - ep.push_back(pi); - } - - for (std::size_t i = 0; i < p.size(); ++i) { - std::sort(p[i].begin(), p[i].end()); - } - std::sort(mp.begin(), mp.end()); - std::sort(ep.begin(), ep.end()); - - double test[] = {0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99}; - for (std::size_t i = 0; i < std::size(test); ++i) { - for (std::size_t j = 0; j < p.size(); ++j) { - LOG_DEBUG(<< j << ") " << test[i] << " " - << static_cast( - std::lower_bound(p[j].begin(), p[j].end(), test[i]) - - p[j].begin()) / - static_cast(p[j].size())); - } - LOG_DEBUG(<< "min " << test[i] << " " - << static_cast( - std::lower_bound(mp.begin(), mp.end(), test[i]) - mp.begin()) / - static_cast(mp.size())); - LOG_DEBUG(<< "corrected min " << test[i] << " " - << static_cast( - std::lower_bound(ep.begin(), ep.end(), test[i]) - ep.begin()) / - static_cast(ep.size())); - } -} - -void dataGenerator() { - const double means[][2] = {{10.0, 20.0}, {30.0, 25.0}, {50.0, 5.0}, {100.0, 50.0}}; - const double covariances[][3] = { - {3.0, 2.0, 2.0}, {6.0, -4.0, 5.0}, {4.0, 1.0, 3.0}, {20.0, -12.0, 12.0}}; - - double anomalies[][4] = {{7000.0, 0.0, 2.8, -2.8}, {7001.0, 0.0, 2.8, -2.8}, - {7002.0, 0.0, 2.8, -2.8}, {7003.0, 0.0, 2.8, -2.8}, - {8000.0, 3.0, 3.5, 4.9}, {8001.0, 3.0, 3.5, 4.9}, - {8002.0, 3.0, 3.5, 4.9}, {8003.0, 3.0, 3.5, 4.9}, - {8004.0, 3.0, 3.5, 4.9}, {8005.0, 3.0, 3.5, 4.9}}; - - test::CRandomNumbers rng; - - TDouble10Vec1Vec samples[4]; - for (std::size_t i = 0; i < std::size(means); ++i) { - gaussianSamples(rng, 10000, means[i], covariances[i], samples[i]); - } - for (std::size_t i = 0; i < std::size(anomalies); ++i) { - std::size_t j = static_cast(anomalies[i][1]); - std::size_t k = static_cast(anomalies[i][0]); - samples[j][k][0] += anomalies[i][2]; - samples[j][k][1] += anomalies[i][3]; - } - - std::ofstream f("four_2d_gaussian.csv"); - core_t::TTime time = 1451606400; - for (std::size_t i = 0; i < 10000; ++i, time += 30) { - for (std::size_t j = 0; j < std::size(samples); ++j) { - f << time << ",x" << 2 * j << "," << samples[j][i][0] << "\n"; - f << time << ",x" << 2 * j + 1 << "," << samples[j][i][1] << "\n"; - } - } -} } BOOST_AUTO_TEST_CASE(testMultipleUpdate) { diff --git a/lib/maths/common/unittest/CToolsTest.cc b/lib/maths/common/unittest/CToolsTest.cc index 12a648518a..5c721e4de7 100644 --- a/lib/maths/common/unittest/CToolsTest.cc +++ b/lib/maths/common/unittest/CToolsTest.cc @@ -1071,7 +1071,8 @@ BOOST_AUTO_TEST_CASE(testMixtureProbabilityOfLessLikelySample) { double pExpected = pTails; CTruncatedPdf pdf(mixture, std::exp(logFx)); for (double xi = a, l = 0, step = 0.5 * (b - a) / std::floor(b - a); - l < 2 * static_cast(b - a); xi += step, ++l) { + l < static_cast(2 * static_cast(b - a)); + xi += step, ++l) { double pi; maths::common::CIntegration::gaussLegendre( pdf, xi, xi + step, pi); diff --git a/lib/maths/time_series/CAdaptiveBucketing.cc b/lib/maths/time_series/CAdaptiveBucketing.cc index 06aac7561a..f892ec824c 100644 --- a/lib/maths/time_series/CAdaptiveBucketing.cc +++ b/lib/maths/time_series/CAdaptiveBucketing.cc @@ -129,7 +129,6 @@ const core::TPersistenceTag LAST_LARGE_ERROR_BUCKET_TAG{"h", "last_large_error_b const core::TPersistenceTag LAST_LARGE_ERROR_PERIOD_TAG{"i", "last_large_error_period"}; const core::TPersistenceTag LARGE_ERROR_COUNT_P_VALUES_TAG{"j", "large_error_counts_p_values"}; const core::TPersistenceTag MEAN_WEIGHT_TAG{"k", "mean weight"}; -const std::string EMPTY_STRING; const double SMOOTHING_FUNCTION[]{0.25, 0.5, 0.25}; const std::size_t WIDTH{std::size(SMOOTHING_FUNCTION) / 2}; diff --git a/lib/maths/time_series/CCalendarComponent.cc b/lib/maths/time_series/CCalendarComponent.cc index a6a317f786..1856f9801f 100644 --- a/lib/maths/time_series/CCalendarComponent.cc +++ b/lib/maths/time_series/CCalendarComponent.cc @@ -33,7 +33,6 @@ namespace { const core::TPersistenceTag DECOMPOSITION_COMPONENT_TAG{"a", "decomposition_component"}; const core::TPersistenceTag BUCKETING_TAG{"b", "bucketing"}; const core::TPersistenceTag LAST_INTERPOLATION_TAG{"c", "last_interpolation_time"}; -const std::string EMPTY_STRING; } CCalendarComponent::CCalendarComponent(const CCalendarFeature& feature, diff --git a/lib/maths/time_series/CCalendarComponentAdaptiveBucketing.cc b/lib/maths/time_series/CCalendarComponentAdaptiveBucketing.cc index e87c16c887..098cc6ceb7 100644 --- a/lib/maths/time_series/CCalendarComponentAdaptiveBucketing.cc +++ b/lib/maths/time_series/CCalendarComponentAdaptiveBucketing.cc @@ -37,7 +37,6 @@ const core::TPersistenceTag ADAPTIVE_BUCKETING_TAG{"a", "adaptive_bucketing"}; const core::TPersistenceTag FEATURE_TAG{"b", "feature"}; const core::TPersistenceTag VALUES_TAG{"c", "values"}; const core::TPersistenceTag TIME_ZONE_OFFSET_TAG{"d", "time_zone"}; -const std::string EMPTY_STRING; } CCalendarComponentAdaptiveBucketing::CCalendarComponentAdaptiveBucketing() diff --git a/lib/maths/time_series/CCalendarCyclicTest.cc b/lib/maths/time_series/CCalendarCyclicTest.cc index 215b396280..955b263167 100644 --- a/lib/maths/time_series/CCalendarCyclicTest.cc +++ b/lib/maths/time_series/CCalendarCyclicTest.cc @@ -415,7 +415,9 @@ double CCalendarCyclicTest::errorsPValue(double n, double nl, double nv) const { double CCalendarCyclicTest::sufficientCountToMeasureLargeErrors() const { // Cap the how long we'll wait identify large errors. - return std::min(static_cast(20 * core::constants::DAY) / m_BucketLength, 100.0); + return std::min(static_cast(20 * core::constants::DAY) / + static_cast(m_BucketLength), + 100.0); } double CCalendarCyclicTest::largeErrorPercentile() const { diff --git a/lib/maths/time_series/CDecompositionComponent.cc b/lib/maths/time_series/CDecompositionComponent.cc index a7587a7f01..11cf5da8f6 100644 --- a/lib/maths/time_series/CDecompositionComponent.cc +++ b/lib/maths/time_series/CDecompositionComponent.cc @@ -50,8 +50,6 @@ const core::TPersistenceTag ESTIMATED_TAG{"a", "estimated"}; const core::TPersistenceTag KNOTS_TAG{"b", "knots"}; const core::TPersistenceTag VALUES_TAG{"c", "values"}; const core::TPersistenceTag VARIANCES_TAG{"d", "variances"}; - -const std::string EMPTY_STRING; } CDecompositionComponent::CDecompositionComponent(std::size_t maxSize, diff --git a/lib/maths/time_series/CSeasonalComponent.cc b/lib/maths/time_series/CSeasonalComponent.cc index 4cfe20870f..1fd66a3f54 100644 --- a/lib/maths/time_series/CSeasonalComponent.cc +++ b/lib/maths/time_series/CSeasonalComponent.cc @@ -39,7 +39,6 @@ const core::TPersistenceTag LAST_INTERPOLATION_TAG{"d", "last_interpolation_time const core::TPersistenceTag TOTAL_SHIFT_TAG{"e", "total_shift"}; const core::TPersistenceTag CURRENT_MEAN_SHIFT_TAG{"f", "current_mean"}; const core::TPersistenceTag MAX_TIME_SHIFT_PER_PERIOD_TAG{"g", "max_time_shift_per_period"}; -const std::string EMPTY_STRING; } CSeasonalComponent::CSeasonalComponent(const CSeasonalTime& time, diff --git a/lib/maths/time_series/CSeasonalComponentAdaptiveBucketing.cc b/lib/maths/time_series/CSeasonalComponentAdaptiveBucketing.cc index 3ea8ea8f97..51b368f70d 100644 --- a/lib/maths/time_series/CSeasonalComponentAdaptiveBucketing.cc +++ b/lib/maths/time_series/CSeasonalComponentAdaptiveBucketing.cc @@ -74,7 +74,6 @@ const core::TPersistenceTag VARIANCE_6_3_TAG{"f", "variance"}; const core::TPersistenceTag FIRST_UPDATE_6_3_TAG{"g", "first_update"}; const core::TPersistenceTag LAST_UPDATE_6_3_TAG{"h", "last_update"}; -const std::string EMPTY_STRING; const core_t::TTime UNSET_TIME{0}; const double SUFFICIENT_INTERVAL_TO_ESTIMATE_SLOPE{2.5}; } diff --git a/lib/maths/time_series/CTimeSeriesDecomposition.cc b/lib/maths/time_series/CTimeSeriesDecomposition.cc index d772b3c37e..0701de7233 100644 --- a/lib/maths/time_series/CTimeSeriesDecomposition.cc +++ b/lib/maths/time_series/CTimeSeriesDecomposition.cc @@ -45,8 +45,6 @@ const core::TPersistenceTag SEASONALITY_TEST_7_11_TAG{"d", "seasonality_test"}; const core::TPersistenceTag CALENDAR_CYCLIC_TEST_7_11_TAG{"e", "calendar_cyclic_test"}; const core::TPersistenceTag COMPONENTS_7_11_TAG{"f", "components"}; const core::TPersistenceTag TIME_SHIFT_7_11_TAG{"g", "time_shift"}; - -const std::string EMPTY_STRING; } CTimeSeriesDecomposition::CTimeSeriesDecomposition(double decayRate, diff --git a/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc b/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc index f8a5f50344..dde65088d3 100644 --- a/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc +++ b/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc @@ -2101,10 +2101,12 @@ void CTimeSeriesDecompositionDetail::CComponents::addSeasonalComponents( LOG_TRACE(<< "remove mask = " << components.seasonalToRemoveMask()); LOG_TRACE(<< "Estimate size change = " - << m_Seasonal->estimateSizeChange(components, m_DecayRate, m_BucketLength)); + << m_Seasonal->estimateSizeChange(components, m_DecayRate, + static_cast(m_BucketLength))); if (memoryCircuitBreaker.areAllocationsAllowed() == false && - m_Seasonal->estimateSizeChange(components, m_DecayRate, m_BucketLength) > 0) { + m_Seasonal->estimateSizeChange(components, m_DecayRate, + static_cast(m_BucketLength)) > 0) { // In the hard_limit state, we do not change the state of components if // adding new components will consume more memory than removing old ones. LOG_TRACE(<< "Not adding new seasonal components because we are in the hard limit state"); diff --git a/lib/maths/time_series/CTimeSeriesDecompositionStateSerialiser.cc b/lib/maths/time_series/CTimeSeriesDecompositionStateSerialiser.cc index e60b10b266..564f6ab79c 100644 --- a/lib/maths/time_series/CTimeSeriesDecompositionStateSerialiser.cc +++ b/lib/maths/time_series/CTimeSeriesDecompositionStateSerialiser.cc @@ -36,7 +36,6 @@ namespace { // DO NOT change the existing tags if new sub-classes are added. const core::TPersistenceTag TIME_SERIES_DECOMPOSITION_TAG("a", "time_series_decomposition"); const core::TPersistenceTag TIME_SERIES_DECOMPOSITION_STUB_TAG("b", "time_series_decomposition_stub"); -const std::string EMPTY_STRING; //! Implements restore for std::shared_ptr. template diff --git a/lib/maths/time_series/unittest/CCalendarCyclicTestTest.cc b/lib/maths/time_series/unittest/CCalendarCyclicTestTest.cc index 3bf891cea1..00f1376dc7 100644 --- a/lib/maths/time_series/unittest/CCalendarCyclicTestTest.cc +++ b/lib/maths/time_series/unittest/CCalendarCyclicTestTest.cc @@ -527,7 +527,8 @@ BOOST_AUTO_TEST_CASE(testLongBuckets) { TDoubleVec error; for (core_t::TTime time = 0, i = 0; time <= end; time += DAY) { rng.generateNormalSamples(0.0, 9.0, 1, error); - if (time >= months[i] && time < months[i] + DAY && i < months.size() - 1) { + if (time >= months[i] && time < months[i] + DAY && + static_cast(i) < months.size() - 1) { error[0] += 20.0; ++i; } diff --git a/lib/model/CAnnotatedProbability.cc b/lib/model/CAnnotatedProbability.cc index 1fd1389854..69d6a48e8d 100644 --- a/lib/model/CAnnotatedProbability.cc +++ b/lib/model/CAnnotatedProbability.cc @@ -30,7 +30,6 @@ const std::string BASELINE_BUCKET_COUNT_TAG("h"); const std::string BASELINE_BUCKET_MEAN_TAG("i"); const std::string ATTRIBUTE_TAG("j"); const std::string FEATURE_TAG("k"); -const std::string DESCRIPTIVE_DATA_TAG("l"); const std::string ANOMALY_TYPE_TAG("m"); const std::string CORRELATED_ATTRIBUTE_TAG("n"); const std::string MULTI_BUCKET_IMPACT_TAG("o"); diff --git a/lib/model/CDataGatherer.cc b/lib/model/CDataGatherer.cc index 8699d508a7..15c41a8b44 100644 --- a/lib/model/CDataGatherer.cc +++ b/lib/model/CDataGatherer.cc @@ -46,8 +46,6 @@ const std::string DEFAULT_ATTRIBUTE_NAME("-"); const std::string PERSON("person"); const std::string ATTRIBUTE("attribute"); -const std::string EMPTY_STRING; - namespace detail { //! Make sure \p features only includes supported features, doesn't diff --git a/lib/model/CDetectorEqualizer.cc b/lib/model/CDetectorEqualizer.cc index cc382b7ca7..69105e5356 100644 --- a/lib/model/CDetectorEqualizer.cc +++ b/lib/model/CDetectorEqualizer.cc @@ -36,8 +36,8 @@ void CDetectorEqualizer::acceptPersistInserter(core::CStatePersistInserter& inse } for (const auto& sketch : m_Sketches) { inserter.insertValue(DETECTOR_TAG, sketch.first); - inserter.insertLevel(SKETCH_TAG, [& sketch = sketch.second](auto& inserter_) { - sketch.acceptPersistInserter(inserter_); + inserter.insertLevel(SKETCH_TAG, [& sketch = sketch.second](auto& subInserter) { + sketch.acceptPersistInserter(subInserter); }); } } @@ -54,8 +54,8 @@ bool CDetectorEqualizer::acceptRestoreTraverser(core::CStateRestoreTraverser& tr LOG_ABORT(<< "Expected the detector label first"); } m_Sketches.emplace_back(*detector, maths::common::CQuantileSketch{SKETCH_SIZE}); - if (traverser.traverseSubLevel([& sketch = m_Sketches.back().second](auto& traverser_) { - return sketch.acceptRestoreTraverser(traverser_); + if (traverser.traverseSubLevel([& sketch = m_Sketches.back().second](auto& subTraverser) { + return sketch.acceptRestoreTraverser(subTraverser); }) == false) { LOG_ERROR(<< "Failed to restore SKETCH_TAG, got " << traverser.value()); m_Sketches.pop_back(); diff --git a/lib/model/CEventRateModel.cc b/lib/model/CEventRateModel.cc index faa16f0e21..ee95c94e43 100644 --- a/lib/model/CEventRateModel.cc +++ b/lib/model/CEventRateModel.cc @@ -490,7 +490,7 @@ bool CEventRateModel::computeProbability(std::size_t pid, bool everSeenBefore = this->firstBucketTimes()[pid] != startTime; auto typicalConcentration = m_Probabilities.medianConcentration(); double actualConcentration; - if (m_ProbabilityPrior.concentration(pid, actualConcentration) && + if (m_ProbabilityPrior.concentration(static_cast(pid), actualConcentration) && typicalConcentration.has_value()) { anomalyScoreExplanation.s_ByFieldActualConcentration = actualConcentration; anomalyScoreExplanation.s_ByFieldTypicalConcentration = diff --git a/lib/model/CMetricBucketGatherer.cc b/lib/model/CMetricBucketGatherer.cc index 19cfb8ccb3..826d6d4372 100644 --- a/lib/model/CMetricBucketGatherer.cc +++ b/lib/model/CMetricBucketGatherer.cc @@ -108,7 +108,6 @@ const std::string MULTIVARIATE_MAX_TAG("k"); const std::string MEDIAN_TAG("l"); const std::string VARIANCE_TAG("m"); const std::string EMPTY_STRING; -const TDoubleVec EMPTY_DOUBLE_VEC; // Nested tags. const std::string ATTRIBUTE_TAG("a"); diff --git a/lib/model/CResourceMonitor.cc b/lib/model/CResourceMonitor.cc index ae175a719a..f08603b57b 100644 --- a/lib/model/CResourceMonitor.cc +++ b/lib/model/CResourceMonitor.cc @@ -415,7 +415,6 @@ std::size_t CResourceMonitor::applyMemoryStrategy(std::size_t usage) const { modifiedUsage = core::CProcessStats::maxResidentSetSize(); break; } - default: { LOG_WARN(<< "Unknown memory strategy"); } } return modifiedUsage; } diff --git a/lib/model/CSearchKey.cc b/lib/model/CSearchKey.cc index 3aacf9eec0..aa95bb773b 100644 --- a/lib/model/CSearchKey.cc +++ b/lib/model/CSearchKey.cc @@ -43,9 +43,6 @@ const std::string EXCLUDE_FREQUENT_TAG("g"); const std::string INFLUENCE_FIELD_NAME_TAG("h"); const std::string IDENTIFIER_TAG("i"); -// AggregateSearchKey -const std::string KEY_TAG("a"); - const std::string EMPTY_STRING; } diff --git a/lib/model/FunctionTypes.cc b/lib/model/FunctionTypes.cc index 78c6274d0c..6e8a4cd262 100644 --- a/lib/model/FunctionTypes.cc +++ b/lib/model/FunctionTypes.cc @@ -1060,7 +1060,6 @@ const TFeatureVec END(detail::POPULATION_SUM_VELOCITY_FEATURES)); const TFeatureVec EMPTY_FEATURES; -const TFunctionVec EMPTY_FUNCTIONS; #undef BEGIN #undef END diff --git a/lib/model/unittest/CModelMemoryTest.cc b/lib/model/unittest/CModelMemoryTest.cc index 87dca727ac..b7550b3560 100644 --- a/lib/model/unittest/CModelMemoryTest.cc +++ b/lib/model/unittest/CModelMemoryTest.cc @@ -67,8 +67,6 @@ void addArrival(CDataGatherer& gatherer, core_t::TTime time, const std::string& CResourceMonitor resourceMonitor; gatherer.addArrival(fieldValues, eventData, resourceMonitor); } - -const std::string EMPTY_STRING; } BOOST_AUTO_TEST_CASE(testOnlineEventRateModel) { diff --git a/lib/model/unittest/CTokenListDataCategorizerTest.cc b/lib/model/unittest/CTokenListDataCategorizerTest.cc index be4e82a83d..88f3b77133 100644 --- a/lib/model/unittest/CTokenListDataCategorizerTest.cc +++ b/lib/model/unittest/CTokenListDataCategorizerTest.cc @@ -524,8 +524,8 @@ BOOST_FIXTURE_TEST_CASE(testPersist, CTestFixture) { std::istringstream origJsonStrm("{\"topLevel\" : " + origJson.str() + "}"); ml::core::CJsonStateRestoreTraverser traverser{origJsonStrm}; BOOST_TEST_REQUIRE(traverser.traverseSubLevel( - [&restoredCategorizer](ml::core::CStateRestoreTraverser& traverser) { - return restoredCategorizer.acceptRestoreTraverser(traverser); + [&restoredCategorizer](ml::core::CStateRestoreTraverser& subTraverser) { + return restoredCategorizer.acceptRestoreTraverser(subTraverser); })); } diff --git a/lib/model/unittest/ModelTestHelpers.h b/lib/model/unittest/ModelTestHelpers.h index 69554cac30..7170fdf2d1 100644 --- a/lib/model/unittest/ModelTestHelpers.h +++ b/lib/model/unittest/ModelTestHelpers.h @@ -27,7 +27,7 @@ namespace model { const CSearchKey KEY; const std::string EMPTY_STRING; -static void testPersistence(const SModelParams& params, +[[maybe_unused]] static void testPersistence(const SModelParams& params, const CDataGatherer& origGatherer, model_t::EAnalysisCategory category) { // Test persistence. (We check for idempotency.) @@ -63,7 +63,7 @@ static void testPersistence(const SModelParams& params, BOOST_REQUIRE_EQUAL(origJson.str(), newJson.str()); } -static void testGathererAttributes(const CDataGatherer& gatherer, +[[maybe_unused]] static void testGathererAttributes(const CDataGatherer& gatherer, core_t::TTime startTime, core_t::TTime bucketLength) { From 1edba0af990ec5cee7878217fbe01a4a0a8040ec Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Fri, 13 Mar 2026 14:04:29 +1300 Subject: [PATCH 02/20] [ML] Run clang-format on compiler warning fixes Made-with: Cursor --- include/maths/common/CBootstrapClusterer.h | 6 ++++-- lib/api/CSingleFieldDataCategorizer.cc | 8 +++++--- lib/api/unittest/CAnomalyJobTest.cc | 4 ++-- lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc | 3 +-- lib/maths/analytics/unittest/CDataFrameUtilsTest.cc | 2 +- .../common/unittest/CMultivariateNormalConjugateTest.cc | 1 - lib/maths/time_series/CTimeSeriesDecompositionDetail.cc | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/maths/common/CBootstrapClusterer.h b/include/maths/common/CBootstrapClusterer.h index 6618cc5ad6..727dbf13c4 100644 --- a/include/maths/common/CBootstrapClusterer.h +++ b/include/maths/common/CBootstrapClusterer.h @@ -731,9 +731,11 @@ class CBootstrapClusterer { parities.swap(best); LOG_TRACE(<< "Best cut |A| = " - << static_cast(std::count(parities.begin(), parities.end(), true)) + << static_cast( + std::count(parities.begin(), parities.end(), true)) << ", |B| = " - << V - static_cast(std::count(parities.begin(), parities.end(), true)) + << V - static_cast( + std::count(parities.begin(), parities.end(), true)) << ", cost = " << cost << ", threshold = " << threshold); return cost < threshold; diff --git a/lib/api/CSingleFieldDataCategorizer.cc b/lib/api/CSingleFieldDataCategorizer.cc index a54e2c232f..8dc854eb51 100644 --- a/lib/api/CSingleFieldDataCategorizer.cc +++ b/lib/api/CSingleFieldDataCategorizer.cc @@ -104,8 +104,9 @@ CSingleFieldDataCategorizer::makeForegroundPersistFunc() const { model::CDataCategorizer::TPersistFunc categorizerPersistFunc{ m_DataCategorizer->makeForegroundPersistFunc()}; - return [ categorizerPersistFuncInner = std::move(categorizerPersistFunc), - this ](core::CStatePersistInserter & inserter) { + return [ + categorizerPersistFuncInner = std::move(categorizerPersistFunc), this + ](core::CStatePersistInserter & inserter) { CSingleFieldDataCategorizer::acceptPersistInserter( categorizerPersistFuncInner, m_DataCategorizer->examplesCollector(), *m_CategoryIdMapper, inserter); @@ -131,7 +132,8 @@ CSingleFieldDataCategorizer::makeBackgroundPersistFunc() const { categoryIdMapperCloneInner = std::move(categoryIdMapperClone) ](core::CStatePersistInserter & inserter) { CSingleFieldDataCategorizer::acceptPersistInserter( - categorizerPersistFuncInner, examplesCollectorInner, *categoryIdMapperCloneInner, inserter); + categorizerPersistFuncInner, examplesCollectorInner, + *categoryIdMapperCloneInner, inserter); }; } diff --git a/lib/api/unittest/CAnomalyJobTest.cc b/lib/api/unittest/CAnomalyJobTest.cc index d59e1af4e0..7bfc25d3a9 100644 --- a/lib/api/unittest/CAnomalyJobTest.cc +++ b/lib/api/unittest/CAnomalyJobTest.cc @@ -321,8 +321,8 @@ BOOST_AUTO_TEST_CASE(testOutputBucketResultsUntilGivenIncompleteInitialBucket) { BOOST_TEST_REQUIRE(jobConfig.initFromFile(configFileName)); model::CAnomalyDetectorModelConfig modelConfig = - model::CAnomalyDetectorModelConfig::defaultConfig(testBucketSize, model_t::E_None, - "", 0, false); + model::CAnomalyDetectorModelConfig::defaultConfig( + testBucketSize, model_t::E_None, "", 0, false); core::CJsonOutputStreamWrapper wrappedOutputStream{outputStrm}; diff --git a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc index 07e84ca65e..f3f48e57f5 100644 --- a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc +++ b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc @@ -2232,8 +2232,7 @@ BOOST_AUTO_TEST_CASE(testProgressMonitoringFromRestart) { TLossFunctionType::E_MseRegression, fieldNames, fieldValues, analyzer, 400); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "", "$"}); - TStrVec persistedStates{ - splitOnNull(std::stringstream{persistenceStream->str()})}; + TStrVec persistedStates{splitOnNull(std::stringstream{persistenceStream->str()})}; LOG_DEBUG(<< "# states = " << persistedStates.size()); diff --git a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc index 8f838bb39f..439ee31977 100644 --- a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc +++ b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc @@ -847,7 +847,7 @@ BOOST_AUTO_TEST_CASE(testDistributionPreservingSamplingRowMasks) { BOOST_REQUIRE_EQUAL(actualCategoryCounts.size(), expectedCategoryCounts.size()); for (std::size_t i = 0; i < expectedCategoryCounts.size(); ++i) { BOOST_REQUIRE_EQUAL(actualCategoryCounts[i], - expectedCategoryCounts[static_cast(i)]); + expectedCategoryCounts[static_cast(i)]); } } diff --git a/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc b/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc index 5254f375b4..6f969d887d 100644 --- a/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc +++ b/lib/maths/common/unittest/CMultivariateNormalConjugateTest.cc @@ -82,7 +82,6 @@ void gaussianSamples(test::CRandomNumbers& rng, } LOG_DEBUG(<< "# samples = " << samples.size()); } - } BOOST_AUTO_TEST_CASE(testMultipleUpdate) { diff --git a/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc b/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc index dde65088d3..5f75725702 100644 --- a/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc +++ b/lib/maths/time_series/CTimeSeriesDecompositionDetail.cc @@ -2106,7 +2106,7 @@ void CTimeSeriesDecompositionDetail::CComponents::addSeasonalComponents( if (memoryCircuitBreaker.areAllocationsAllowed() == false && m_Seasonal->estimateSizeChange(components, m_DecayRate, - static_cast(m_BucketLength)) > 0) { + static_cast(m_BucketLength)) > 0) { // In the hard_limit state, we do not change the state of components if // adding new components will consume more memory than removing old ones. LOG_TRACE(<< "Not adding new seasonal components because we are in the hard limit state"); From 27e3df79f7aab1f5675f55a08ac04467744317a0 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Fri, 13 Mar 2026 14:38:00 +1300 Subject: [PATCH 03/20] [ML] Fix deprecated implicit this capture via [=] in C++20 Change [=] to [this, f] in CConcurrentWrapper to silence -Wdeprecated on GCC 13 and Clang. Made-with: Cursor --- include/core/CConcurrentWrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/core/CConcurrentWrapper.h b/include/core/CConcurrentWrapper.h index 610277f637..54ee254a45 100644 --- a/include/core/CConcurrentWrapper.h +++ b/include/core/CConcurrentWrapper.h @@ -58,7 +58,7 @@ class CConcurrentWrapper final : private CNonCopyable { //! The code inside of this lambda is guaranteed to be executed in an atomic fashion. template void operator()(F f) const { - m_Queue.push([=] { f(m_Resource); }); + m_Queue.push([this, f] { f(m_Resource); }); } //! Debug the memory used by this component. From 5e44996c84bc83465832b8e6aa543b6655aef300 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Fri, 13 Mar 2026 15:22:18 +1300 Subject: [PATCH 04/20] Formatting --- lib/model/unittest/ModelTestHelpers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/model/unittest/ModelTestHelpers.h b/lib/model/unittest/ModelTestHelpers.h index 7170fdf2d1..4155187c3a 100644 --- a/lib/model/unittest/ModelTestHelpers.h +++ b/lib/model/unittest/ModelTestHelpers.h @@ -28,8 +28,8 @@ const CSearchKey KEY; const std::string EMPTY_STRING; [[maybe_unused]] static void testPersistence(const SModelParams& params, - const CDataGatherer& origGatherer, - model_t::EAnalysisCategory category) { + const CDataGatherer& origGatherer, + model_t::EAnalysisCategory category) { // Test persistence. (We check for idempotency.) std::ostringstream origJson; core::CJsonStatePersistInserter::persist( @@ -64,8 +64,8 @@ const std::string EMPTY_STRING; } [[maybe_unused]] static void testGathererAttributes(const CDataGatherer& gatherer, - core_t::TTime startTime, - core_t::TTime bucketLength) { + core_t::TTime startTime, + core_t::TTime bucketLength) { BOOST_REQUIRE_EQUAL(1, gatherer.numberActivePeople()); BOOST_REQUIRE_EQUAL(1, gatherer.numberByFieldValues()); From fe09511ef4345f80d1132eb46f7b994ad134ce19 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Tue, 24 Mar 2026 15:11:51 +1300 Subject: [PATCH 05/20] [ML] Initialise tokenTypeName to "unknown" for future-proofing Address Copilot review: if a new enum value is added to SBoostJsonHandler, the switch won't cover it and the log message would contain an empty string. Initialising to "unknown" keeps the error log informative. Made-with: Cursor --- lib/core/CJsonStateRestoreTraverser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/CJsonStateRestoreTraverser.cc b/lib/core/CJsonStateRestoreTraverser.cc index 333af1f56b..2b62c4478f 100644 --- a/lib/core/CJsonStateRestoreTraverser.cc +++ b/lib/core/CJsonStateRestoreTraverser.cc @@ -319,7 +319,7 @@ bool CJsonStateRestoreTraverser::start() { } // Enhanced error logging with comprehensive debugging information - std::string tokenTypeName; + std::string tokenTypeName{"unknown"}; switch (m_Handler.s_Type) { case SBoostJsonHandler::E_TokenNull: tokenTypeName = "null"; From 76a6eb12ce7825daa7e52d0dcaa058c5d864b1fa Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 11:09:27 +1200 Subject: [PATCH 06/20] [ML] Fix category count comparison to iterate map keys Address Copilot review: the loop assumed contiguous integer category IDs (0..N-1) and used operator[] which silently inserts missing keys. Iterate over actual map entries instead. Made-with: Cursor --- lib/maths/analytics/unittest/CDataFrameUtilsTest.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc index 439ee31977..16b161d38c 100644 --- a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc +++ b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc @@ -845,9 +845,10 @@ BOOST_AUTO_TEST_CASE(testDistributionPreservingSamplingRowMasks) { LOG_TRACE(<< "Actual category count " << actualCategoryCounts); BOOST_REQUIRE_EQUAL(actualCategoryCounts.size(), expectedCategoryCounts.size()); - for (std::size_t i = 0; i < expectedCategoryCounts.size(); ++i) { - BOOST_REQUIRE_EQUAL(actualCategoryCounts[i], - expectedCategoryCounts[static_cast(i)]); + for (const auto & [ category, expected ] : expectedCategoryCounts) { + auto index = static_cast(category); + BOOST_TEST_REQUIRE(index < actualCategoryCounts.size()); + BOOST_REQUIRE_EQUAL(actualCategoryCounts[index], expected); } } From 2268efc7ddb9d2e455909d8dbcfb363ce1e1d398 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 13:38:06 +1200 Subject: [PATCH 07/20] [ML] Fix high-priority compiler warnings (potential bugs) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CDataFrameTrainBoostedTreeRunner: add LOG_ABORT after 3 exhaustive switch statements that had no default — falling off the end of a non-void function is undefined behaviour (MSVC C4715, GCC -Wreturn-type) - CBoostedTreeHyperparameters: initialise hyperparameterValue to 0.0 — previously uninitialised if a new enum value was added without updating the switch (MSVC C4701) - CJsonLogLayout: remove dangling reference to temporary from boost::log::extract().get() — binding const auto& to the result of .get() on a temporary extractor leaves the reference dangling after the full expression ends (GCC -Wdangling-reference) Made-with: Cursor --- lib/api/CDataFrameTrainBoostedTreeRunner.cc | 3 +++ lib/core/CJsonLogLayout.cc | 12 ++++++------ lib/maths/analytics/CBoostedTreeHyperparameters.cc | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/api/CDataFrameTrainBoostedTreeRunner.cc b/lib/api/CDataFrameTrainBoostedTreeRunner.cc index 09fdd78307..0983defbcb 100644 --- a/lib/api/CDataFrameTrainBoostedTreeRunner.cc +++ b/lib/api/CDataFrameTrainBoostedTreeRunner.cc @@ -340,6 +340,7 @@ std::size_t CDataFrameTrainBoostedTreeRunner::numberExtraColumns() const { return maths::analytics::CBoostedTreeFactory::estimateExtraColumnsForPredict( m_DimensionPrediction); } + LOG_ABORT(<< "Unexpected task type"); } std::size_t CDataFrameTrainBoostedTreeRunner::dataFrameSliceCapacity() const { @@ -372,6 +373,7 @@ CDataFrameTrainBoostedTreeRunner::rowsToWriteMask(const core::CDataFrame& frame) case api_t::E_Update: return m_BoostedTree->newTrainingRowMask(); } + LOG_ABORT(<< "Unexpected task type"); } const std::string& CDataFrameTrainBoostedTreeRunner::dependentVariableFieldName() const { @@ -595,6 +597,7 @@ std::size_t CDataFrameTrainBoostedTreeRunner::estimateBookkeepingMemoryUsage( return m_TrainedModelMemoryUsage + m_BoostedTreeFactory->estimateMemoryUsageForPredict( numberTrainingRows, numberColumns); } + LOG_ABORT(<< "Unexpected task type"); } const CDataFrameAnalysisInstrumentation& diff --git a/lib/core/CJsonLogLayout.cc b/lib/core/CJsonLogLayout.cc index baf765683a..5a7a1f9315 100644 --- a/lib/core/CJsonLogLayout.cc +++ b/lib/core/CJsonLogLayout.cc @@ -68,9 +68,9 @@ void CJsonLogLayout::operator()(const boost::log::record_view& rec, json::object writer; writer[LOGGER_NAME] = LOGGER; - const auto& timeStamp = boost::log::extract( - boost::log::aux::default_attribute_names::timestamp(), rec) - .get(); + const auto timeStamp = boost::log::extract( + boost::log::aux::default_attribute_names::timestamp(), rec) + .get(); writer[TIMESTAMP_NAME] = (timeStamp - EPOCH).total_milliseconds(); auto level = boost::log::extract( @@ -102,9 +102,9 @@ void CJsonLogLayout::operator()(const boost::log::record_view& rec, writer[METHOD_NAME] = methodName; - const auto& fullFileName = boost::log::extract( - CLogger::instance().fileAttributeName(), rec) - .get(); + const auto fullFileName = boost::log::extract( + CLogger::instance().fileAttributeName(), rec) + .get(); writer[FILE_NAME] = CJsonLogLayout::cropPath(fullFileName); writer[LINE_NAME] = diff --git a/lib/maths/analytics/CBoostedTreeHyperparameters.cc b/lib/maths/analytics/CBoostedTreeHyperparameters.cc index 78add5f5c9..4809f96024 100644 --- a/lib/maths/analytics/CBoostedTreeHyperparameters.cc +++ b/lib/maths/analytics/CBoostedTreeHyperparameters.cc @@ -569,7 +569,7 @@ CBoostedTreeHyperparameters::importances() const { for (std::size_t i = 0; i < static_cast(NUMBER_HYPERPARAMETERS); ++i) { auto hyperparameter = static_cast(i); - double hyperparameterValue; + double hyperparameterValue{0.0}; SHyperparameterImportance::EType hyperparameterType{SHyperparameterImportance::E_Double}; bool skip{false}; switch (hyperparameter) { From 505dcf2e45786ad02f41bc1b57de4404c2004dae Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 13:49:45 +1200 Subject: [PATCH 08/20] [ML] Fix remaining [=] implicit this captures for C++20 Change [=] to [=, this] in 6 lambdas that capture this. Implicit this capture via [=] is deprecated in C++20. (GCC -Wdeprecated) Made-with: Cursor --- lib/core/CDataFrame.cc | 4 ++-- lib/maths/common/CBayesianOptimisation.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/core/CDataFrame.cc b/lib/core/CDataFrame.cc index ad004c89ed..d09762cd4b 100644 --- a/lib/core/CDataFrame.cc +++ b/lib/core/CDataFrame.cc @@ -550,7 +550,7 @@ bool CDataFrame::parallelApplyToAllRows(std::size_t beginRows, sliceFuncs.reserve(funcs.size()); for (auto& func : funcs) { - sliceFuncs.push_back([=, &func, &successful](const TRowSlicePtr& slice) mutable { + sliceFuncs.push_back([=, this, &func, &successful](const TRowSlicePtr& slice) mutable { if (successful.load() == false) { return; } @@ -639,7 +639,7 @@ bool CDataFrame::sequentialApplyToAllRows(std::size_t beginRows, backgroundApply = async( defaultAsyncExecutor(), - [ =, &func, readSlice_ = std::move(readSlice) ]() mutable { + [ =, this, &func, readSlice_ = std::move(readSlice) ]() mutable { TOptionalPopMaskedRow popMaskedRow; if (rowMask != nullptr) { diff --git a/lib/maths/common/CBayesianOptimisation.cc b/lib/maths/common/CBayesianOptimisation.cc index bbd7baae89..35385da5f3 100644 --- a/lib/maths/common/CBayesianOptimisation.cc +++ b/lib/maths/common/CBayesianOptimisation.cc @@ -483,7 +483,7 @@ CBayesianOptimisation::minusLikelihoodAndGradient() const { // denote the Eigenvalues of the nullspace. We use a rank revealing decomposition // and compute the likelihood on the row space. - auto minusLogLikelihood = [=](const TVector& a) mutable -> double { + auto minusLogLikelihood = [=, this](const TVector& a) mutable -> double { K = this->kernel(a, v + eps); Kqr.compute(K); Kinvf.noalias() = Kqr.solve(f); @@ -496,7 +496,7 @@ CBayesianOptimisation::minusLikelihoodAndGradient() const { return 0.5 * (f.transpose() * Kinvf + logAbsDet); }; - auto minusLogLikelihoodGradient = [=](const TVector& a) mutable -> TVector { + auto minusLogLikelihoodGradient = [=, this](const TVector& a) mutable -> TVector { K = this->kernel(a, v + eps); Kqr.compute(K); @@ -548,7 +548,7 @@ CBayesianOptimisation::minusExpectedImprovementAndGradient() const { }) ->second}; - auto EI = [=](const TVector& x) mutable -> double { + auto EI = [=, this](const TVector& x) mutable -> double { double Kxx; std::tie(Kxn, Kxx) = this->kernelCovariates(m_KernelParameters, x, vx); if (CMathsFuncs::isNan(Kxx)) { @@ -575,7 +575,7 @@ CBayesianOptimisation::minusExpectedImprovementAndGradient() const { return -sigma * (z * cdfz + pdfz); }; - auto EIGradient = [=](const TVector& x) mutable -> TVector { + auto EIGradient = [=, this](const TVector& x) mutable -> TVector { double Kxx; std::tie(Kxn, Kxx) = this->kernelCovariates(m_KernelParameters, x, vx); if (CMathsFuncs::isNan(Kxx)) { From 43045d95d30a303e2d2ae5bfa425ba562849d564 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 13:54:13 +1200 Subject: [PATCH 09/20] [ML] Fix implicit size_t to double conversions Add static_cast at 7 locations where size_t values are implicitly converted to double. (GCC -Wconversion, MSVC C4244/C4267) Made-with: Cursor --- .../CDataFrameAnalyzerTrainingTest.cc | 6 ++-- lib/core/CDataFrame.cc | 33 ++++++++++--------- .../analytics/unittest/CDataFrameUtilsTest.cc | 7 ++-- lib/maths/time_series/unittest/CSignalTest.cc | 3 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc index f3f48e57f5..04e9696ff9 100644 --- a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc +++ b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc @@ -896,7 +896,8 @@ BOOST_AUTO_TEST_CASE(testRegressionPredictionNumericalOnly, *utf::tolerance(0.00 }}; std::size_t numberExamples{ - static_cast(trainExamples * dataSummarizationFraction) + predictExamples}; + static_cast(static_cast(trainExamples) * dataSummarizationFraction) + + predictExamples}; runAnalyzer(numberExamples, predictExamples, TTask::E_Predict, &restorerSupplier); readPredictions(outputStream.str(), "target_prediction", actualPredictions); } @@ -992,7 +993,8 @@ BOOST_AUTO_TEST_CASE(testRegressionPredictionNumericalCategoricalMix, }}; std::size_t numberExamples{ - static_cast(trainExamples * dataSummarizationFraction) + predictExamples}; + static_cast(static_cast(trainExamples) * dataSummarizationFraction) + + predictExamples}; runAnalyzer(numberExamples, predictExamples, TTask::E_Predict, &restorerSupplier); readPredictions(outputStream.str(), "target_prediction", actualPredictions); } diff --git a/lib/core/CDataFrame.cc b/lib/core/CDataFrame.cc index d09762cd4b..752feaf13a 100644 --- a/lib/core/CDataFrame.cc +++ b/lib/core/CDataFrame.cc @@ -508,8 +508,9 @@ std::size_t CDataFrame::estimateMemoryUsage(bool inMainMemory, // We use an "uncertainty percentage factor" to account for this. static constexpr double containerMemoryEstimateUncertaintyPercentage{2.5}; - std::size_t additionalMemory{static_cast( - estimatedMemoryUsage * containerMemoryEstimateUncertaintyPercentage / 100)}; + std::size_t additionalMemory{ + static_cast(static_cast(estimatedMemoryUsage) * + containerMemoryEstimateUncertaintyPercentage / 100)}; return estimatedMemoryUsage + additionalMemory; } @@ -637,23 +638,23 @@ bool CDataFrame::sequentialApplyToAllRows(std::size_t beginRows, // We wait here so at most one slice is copied into memory. wait_for_valid(backgroundApply); - backgroundApply = async( - defaultAsyncExecutor(), - [ =, this, &func, readSlice_ = std::move(readSlice) ]() mutable { + backgroundApply = async(defaultAsyncExecutor(), [ + =, this, &func, readSlice_ = std::move(readSlice) + ]() mutable { - TOptionalPopMaskedRow popMaskedRow; - if (rowMask != nullptr) { - beginSliceRows = *maskedRow; - popMaskedRow = CPopMaskedRow{endSliceRows, maskedRow, endMaskedRows}; - } + TOptionalPopMaskedRow popMaskedRow; + if (rowMask != nullptr) { + beginSliceRows = *maskedRow; + popMaskedRow = CPopMaskedRow{endSliceRows, maskedRow, endMaskedRows}; + } - this->applyToRowsOfOneSlice(func[0], beginSliceRows, endSliceRows, - popMaskedRow, readSlice_); + this->applyToRowsOfOneSlice(func[0], beginSliceRows, endSliceRows, + popMaskedRow, readSlice_); - if (commitResult) { - (*slice)->write(readSlice_.rows(), readSlice_.docHashes()); - } - }); + if (commitResult) { + (*slice)->write(readSlice_.rows(), readSlice_.docHashes()); + } + }); } break; } diff --git a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc index 16b161d38c..87f561941a 100644 --- a/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc +++ b/lib/maths/analytics/unittest/CDataFrameUtilsTest.cc @@ -704,7 +704,8 @@ BOOST_AUTO_TEST_CASE(testStratifiedSamplingRowMasks) { testRng.generateNormalSamples(0.0, 3.0, numberRows, categories); testRng.generateUniformSamples(200, 500, 1, desiredNumberSamples); - double desiredSamplesFraction{static_cast(desiredNumberSamples[0]) / numberRows}; + double desiredSamplesFraction{static_cast(desiredNumberSamples[0]) / + static_cast(numberRows)}; auto frame = core::makeMainStorageDataFrame(numberCols).first; frame->categoricalColumns(TBoolVec{true}); @@ -780,7 +781,7 @@ BOOST_AUTO_TEST_CASE(testStratifiedSamplingRowMasks) { } } - double percentageStep{1.0 / numberBins * 100.0}; + double percentageStep{1.0 / static_cast(numberBins) * 100.0}; double expected; double actual; for (double percentage = percentageStep; percentage < 100.0; @@ -896,7 +897,7 @@ BOOST_AUTO_TEST_CASE(testDistributionPreservingSamplingRowMasks) { } } - double percentageStep{1.0 / numberBins * 100.0}; + double percentageStep{1.0 / static_cast(numberBins) * 100.0}; double expected; double actual; for (double percentage = percentageStep; percentage < 100.0; diff --git a/lib/maths/time_series/unittest/CSignalTest.cc b/lib/maths/time_series/unittest/CSignalTest.cc index 6a182b35ad..232b725d92 100644 --- a/lib/maths/time_series/unittest/CSignalTest.cc +++ b/lib/maths/time_series/unittest/CSignalTest.cc @@ -639,7 +639,8 @@ BOOST_AUTO_TEST_CASE(testFitSingleSeasonalComponent) { BOOST_REQUIRE_EQUAL(period, actuals[0].size()); TMeanVarAccumulator meanError; - double sigma{std::sqrt(4.0 / (static_cast(values.size()) / period))}; + double sigma{std::sqrt(4.0 / (static_cast(values.size()) / + static_cast(period)))}; for (std::size_t i = 0; i < actuals[0].size(); ++i) { BOOST_REQUIRE_CLOSE_ABSOLUTE( expected(i), maths::common::CBasicStatistics::mean(actuals[0][i]), From 63e3e8502843f7832eef214bd129881b54a7e5e4 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 13:59:02 +1200 Subject: [PATCH 10/20] [ML] Suppress MSVC C4723 in CMathsFuncsTest The test deliberately divides by zero to verify edge-case handling in CMathsFuncs. Suppress C4723 for this file only. Made-with: Cursor --- lib/maths/common/unittest/CMathsFuncsTest.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/maths/common/unittest/CMathsFuncsTest.cc b/lib/maths/common/unittest/CMathsFuncsTest.cc index 7e5999bfd5..e54c8c8693 100644 --- a/lib/maths/common/unittest/CMathsFuncsTest.cc +++ b/lib/maths/common/unittest/CMathsFuncsTest.cc @@ -13,6 +13,11 @@ #include +// This test deliberately divides by zero to verify edge-case handling. +#ifdef _MSC_VER +#pragma warning(disable : 4723) // potential divide by 0 +#endif + #include #include #include From b3bf9957ae32eb9c17176a879dcd99fa0ad70f0c Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 13:59:42 +1200 Subject: [PATCH 11/20] [ML] Suppress Clang -Wunused-macros BOOST_TEST_MODULE and BOOST_TEST_NO_MAIN are consumed by the subsequent #include but Clang flags them as unused since they're not referenced directly in source. This is a known false positive with Boost.Test's macro-driven configuration pattern. Made-with: Cursor --- cmake/compiler/clang.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/compiler/clang.cmake b/cmake/compiler/clang.cmake index 7dd8adf360..0333e246a5 100644 --- a/cmake/compiler/clang.cmake +++ b/cmake/compiler/clang.cmake @@ -37,6 +37,7 @@ list(APPEND ML_C_FLAGS "-Wno-switch-default" "-Wno-unknown-warning-option" "-Wno-unreachable-code" + "-Wno-unused-macros" "-Wno-used-but-marked-unused" ${ML_COVERAGE}) From 4b7e9a52a6855d2c9eb7254c271faffe7859a6f4 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 8 Apr 2026 14:00:57 +1200 Subject: [PATCH 12/20] [ML] Suppress Clang -Wunused-macros for test targets only BOOST_TEST_MODULE and BOOST_TEST_NO_MAIN are consumed by the subsequent #include but Clang flags them as unused since they're not referenced directly in source. Suppress for test targets only via target_compile_options in ml_add_test_executable, rather than globally. Made-with: Cursor --- cmake/compiler/clang.cmake | 1 - cmake/compiler/msvc.cmake | 4 ++++ cmake/functions.cmake | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmake/compiler/clang.cmake b/cmake/compiler/clang.cmake index 0333e246a5..7dd8adf360 100644 --- a/cmake/compiler/clang.cmake +++ b/cmake/compiler/clang.cmake @@ -37,7 +37,6 @@ list(APPEND ML_C_FLAGS "-Wno-switch-default" "-Wno-unknown-warning-option" "-Wno-unreachable-code" - "-Wno-unused-macros" "-Wno-used-but-marked-unused" ${ML_COVERAGE}) diff --git a/cmake/compiler/msvc.cmake b/cmake/compiler/msvc.cmake index d6385aef2e..b97922ac33 100644 --- a/cmake/compiler/msvc.cmake +++ b/cmake/compiler/msvc.cmake @@ -27,10 +27,14 @@ list(APPEND ML_COMPILE_DEFINITIONS _WIN32_WINNT=0x0601 Windows) +# Treat SYSTEM include directories as external — suppress warnings from +# third-party headers (Boost, Eigen, PyTorch, etc.). Requires MSVC 17.0+. +set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/external:I ") list(APPEND ML_C_FLAGS "/X" "/nologo" "/W4" + "/external:W0" "/EHsc" "/Gw" "/Zc:inline" diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 872bf3c6d1..42c886444c 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -382,6 +382,12 @@ function(ml_add_test_executable _target) set_property(TARGET ml_test_${_target} PROPERTY POSITION_INDEPENDENT_CODE TRUE) + # Boost.Test's BOOST_TEST_MODULE / BOOST_TEST_NO_MAIN macros are consumed + # by the subsequent #include but Clang flags + # them as unused. Suppress for test targets only. + target_compile_options(ml_test_${_target} PRIVATE + $<$:-Wno-unused-macros>) + if(ML_PCH) target_precompile_headers(ml_test_${_target} PRIVATE From c29ff6a1334e50e24b80c68f59390334cd13604c Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 29 Jul 2026 15:56:10 +1200 Subject: [PATCH 13/20] [ML] Replace deprecated std::is_pod with ml::core::is_pod_v (MSVC C4996) std::is_pod is deprecated in C++20; a single instantiation in the widely included CMemoryFwd.h produced ~454 MSVC C4996 warnings. Introduce a project-level ml::core::is_pod_v alias defined as is_trivial_v && is_standard_layout_v (the standard's exact definition of POD), verified equivalent to std::is_pod across fundamentals, cv/pointer/array qualification, enums, unions, aggregates, standard-layout inheritance edge cases and library types. Adds a guarding unit test. Co-authored-by: Cursor --- include/core/CMemoryFwd.h | 14 +++++++- lib/core/unittest/CMemoryUsageTest.cc | 49 ++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/include/core/CMemoryFwd.h b/include/core/CMemoryFwd.h index 9b78783681..4b404e959f 100644 --- a/include/core/CMemoryFwd.h +++ b/include/core/CMemoryFwd.h @@ -20,11 +20,23 @@ namespace ml { namespace core { + +//! C++20-safe replacement for the deprecated \c std::is_pod / \c std::is_pod_v. +//! +//! \c std::is_pod was deprecated in C++20. The standard defines a POD type as +//! one that is both trivial and standard-layout, so this reproduces +//! \c std::is_pod_v exactly - verified equivalent across fundamentals, cv- and +//! pointer-qualified types, arrays, enums, unions, aggregates, inheritance +//! (standard-layout) edge cases and library types - without emitting the +//! deprecation warning (MSVC C4996 / \c -Wdeprecated-declarations). +template +inline constexpr bool is_pod_v = std::is_trivial_v&& std::is_standard_layout_v; + namespace memory_detail { //! \brief Base implementation checks for POD. template struct SDynamicSizeAlwaysZero { - static constexpr inline bool value() { return std::is_pod::value; } + static constexpr inline bool value() { return is_pod_v; } }; //! \brief Checks types in pair. diff --git a/lib/core/unittest/CMemoryUsageTest.cc b/lib/core/unittest/CMemoryUsageTest.cc index 3fc0cc8c69..c5b4b30525 100644 --- a/lib/core/unittest/CMemoryUsageTest.cc +++ b/lib/core/unittest/CMemoryUsageTest.cc @@ -865,7 +865,7 @@ BOOST_AUTO_TEST_CASE(testDynamicSizeAlwaysZero) { BOOST_REQUIRE_EQUAL(true, test); test = core::memory_detail::SDynamicSizeAlwaysZero>::value(); BOOST_REQUIRE_EQUAL(true, test); - test = std::is_pod::value; + test = core::is_pod_v; BOOST_REQUIRE_EQUAL(false, test); test = core::memory_detail::SDynamicSizeAlwaysZero::value(); BOOST_REQUIRE_EQUAL(true, test); @@ -883,6 +883,53 @@ BOOST_AUTO_TEST_CASE(testDynamicSizeAlwaysZero) { BOOST_REQUIRE_EQUAL(false, test); } +BOOST_AUTO_TEST_CASE(testIsPodV) { + // core::is_pod_v is the C++20-safe replacement for the deprecated + // std::is_pod. Guard that it reports the expected POD-ness across the type + // categories that matter for memory accounting. Expected values are the + // same as std::is_pod would give (trivial && standard-layout). + struct SPodLike { + int a; + double b; + }; + struct SWithCtor { + int a; + SWithCtor() : a(0) {} + }; + struct SWithVirtual { + virtual ~SWithVirtual() = default; + }; + struct SBase { + int a; + }; + struct SDerivedNoData : SBase {}; + struct SDerivedWithData : SBase { + int b; + }; + union UPod { + int i; + float f; + }; + + // POD types. + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + // Single base with no own data members is still standard-layout + trivial. + BOOST_REQUIRE_EQUAL(true, (core::is_pod_v)); + + // Non-POD types. + BOOST_REQUIRE_EQUAL(false, (core::is_pod_v)); // non-trivial + BOOST_REQUIRE_EQUAL(false, (core::is_pod_v)); // user ctor + BOOST_REQUIRE_EQUAL(false, (core::is_pod_v)); // vtable + BOOST_REQUIRE_EQUAL(false, (core::is_pod_v)); // data in base and derived + BOOST_REQUIRE_EQUAL(false, (core::is_pod_v>)); // pair has user ctors +} + BOOST_AUTO_TEST_CASE(testCompress) { { // Check that non-repeated entries are not removed From 47bc55faab8bf309a9e18e3a4a717ae0a6b748a3 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 29 Jul 2026 16:04:16 +1200 Subject: [PATCH 14/20] [ML] Suppress MSVC C4250 (dominance) for instrumentation diamond C4250 is a purely informational MSVC-only diagnostic (92 warnings from CDataFrameAnalysisInstrumentation.h). The instrumentation hierarchy uses a deliberate virtual-inheritance mixin where CDataFrameAnalysisInstrumentation provides the shared implementation and the per-analysis interfaces add their own pure virtuals; the standard dominance rule resolves this correctly and GCC/Clang do not warn. Suppress rather than redesign a working hierarchy. Co-authored-by: Cursor --- cmake/compiler/msvc.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/compiler/msvc.cmake b/cmake/compiler/msvc.cmake index b97922ac33..17d078cc23 100644 --- a/cmake/compiler/msvc.cmake +++ b/cmake/compiler/msvc.cmake @@ -51,6 +51,12 @@ list(APPEND ML_CXX_FLAGS "/we4150" "/wd4201" "/wd4231" + # C4250 ("inherits via dominance") is a purely informational MSVC-only + # diagnostic. The instrumentation classes use a deliberate virtual-inheritance + # mixin (CDataFrameAnalysisInstrumentation supplies the shared implementation + # while the per-analysis interfaces add their own pure virtuals); the C++ + # dominance rule resolves the shared methods correctly. GCC/Clang do not warn. + "/wd4250" "/wd4251" "/wd4355" "/wd4512" From b7a79e543ab01977b20f37bfc310cd07d862d7be Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 29 Jul 2026 16:07:39 +1200 Subject: [PATCH 15/20] [ML] Suppress GCC -Wsubobject-linkage for test targets only Boost.Test fixture macros generate externally-linked test classes deriving from fixtures declared in anonymous namespaces (internal linkage), which GCC flags with -Wsubobject-linkage (23 warnings across 4 test files). The anonymous namespace is intentional - it keeps per-file fixtures ODR-distinct within the monolithic per-library test binary, so moving them to a shared named namespace would risk ODR violations. Scope the suppression to ml_test_* targets so production code retains the warning. Co-authored-by: Cursor --- cmake/functions.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 2025a27410..a38bda85c3 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -382,6 +382,16 @@ function(ml_add_test_executable _target) set_property(TARGET ml_test_${_target} PROPERTY POSITION_INDEPENDENT_CODE TRUE) + # Boost.Test's fixture macros generate test classes with external linkage that + # derive from fixtures defined in anonymous namespaces (internal linkage). GCC + # flags this idiomatic, benign pattern with -Wsubobject-linkage. The anonymous + # namespace is deliberate: it keeps each file's fixtures ODR-distinct within + # the monolithic per-library test binary. Silence the warning for test targets + # only, leaving it active for production code. + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(ml_test_${_target} PRIVATE "-Wno-subobject-linkage") + endif() + # Boost.Test's BOOST_TEST_MODULE / BOOST_TEST_NO_MAIN macros are consumed # by the subsequent #include but Clang flags # them as unused. Suppress for test targets only. From f1ff6d348e1439b52c03386f493ecac95173922a Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Wed, 29 Jul 2026 16:23:45 +1200 Subject: [PATCH 16/20] [ML] Add CResultType operator| overloads to fix deprecated enum-enum OR Combining the two orthogonal CResultType flag enums (EInterimOrFinal, EConditionalOrUnconditional) with the built-in bitwise OR is deprecated in C++20 (GCC -Wdeprecated-enum-enum-conversion / MSVC C5054), producing 14 warnings across 3 model test files. Provide operator| overloads for the two cross-enum combinations returning CResultType; being exact matches they are selected ahead of the built-in operator, clearing the warnings with no call-site changes. Same-enum ORs are unaffected. Co-authored-by: Cursor --- include/model/ModelTypes.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/model/ModelTypes.h b/include/model/ModelTypes.h index acbcc14c04..f07753215f 100644 --- a/include/model/ModelTypes.h +++ b/include/model/ModelTypes.h @@ -122,6 +122,24 @@ class MODEL_EXPORT CResultType { unsigned int m_Type; }; +//! Combine the two orthogonal \c CResultType flag enums into a result type. +//! +//! \c EInterimOrFinal and \c EConditionalOrUnconditional occupy disjoint bits, +//! so callers combine them with e.g. \c E_Unconditional | \c E_Interim. These +//! overloads make that combination explicit and, being exact matches, are +//! chosen ahead of the built-in operator - avoiding the C++20 deprecation of +//! bitwise operations between different enumeration types (GCC +//! -Wdeprecated-enum-enum-conversion / MSVC C5054). +inline CResultType operator|(CResultType::EConditionalOrUnconditional lhs, + CResultType::EInterimOrFinal rhs) { + return CResultType{static_cast(lhs) | static_cast(rhs)}; +} + +inline CResultType operator|(CResultType::EInterimOrFinal lhs, + CResultType::EConditionalOrUnconditional rhs) { + return CResultType{static_cast(lhs) | static_cast(rhs)}; +} + //! The feature naming is systematic and all subsequent feature //! names should conform to the following syntax:\n //! E_(Individual|Population|Peers)\[By|Of][Bucket][And][Person][And][Attribute]\n From a93378d1ad94759aa59d9bb2bf734b92472b3abf Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Thu, 30 Jul 2026 10:05:58 +1200 Subject: [PATCH 17/20] [ML] Suppress MSVC C4324 for intended alignas padding C4324 ("structure was padded due to alignment specifier") fires for types that deliberately over-align members with alignas to avoid false sharing, e.g. the std::atomic counters in CCompressedLfuCache. The padding is the intended effect of the alignment, so the diagnostic is pure noise (~12 occurrences). GCC/Clang do not warn. Suppress it alongside the other MSVC-only informational diagnostics. Co-authored-by: Cursor --- cmake/compiler/msvc.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/compiler/msvc.cmake b/cmake/compiler/msvc.cmake index 17d078cc23..a90d9c0bf2 100644 --- a/cmake/compiler/msvc.cmake +++ b/cmake/compiler/msvc.cmake @@ -58,6 +58,12 @@ list(APPEND ML_CXX_FLAGS # dominance rule resolves the shared methods correctly. GCC/Clang do not warn. "/wd4250" "/wd4251" + # C4324 ("structure was padded due to alignment specifier") is emitted for + # types that deliberately over-align members with alignas to avoid false + # sharing (e.g. the std::atomic counters in CCompressedLfuCache). The padding + # is the intended consequence of the alignment, so the diagnostic is pure + # noise here. GCC/Clang do not warn. + "/wd4324" "/wd4355" "/wd4512" "/wd4702" From b6536f65f22b8bf239ba6889ff7068e896c962ac Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Thu, 30 Jul 2026 10:05:58 +1200 Subject: [PATCH 18/20] [ML] Fix implicit narrowing in central-moments custom add SCentralMomentsCustomAdd::add cast the count n to double before forwarding to SSampleCentralMoments::add, whose parameter is const TCoordinate&. For float coordinates that introduced a TCoordinate -> double -> TCoordinate narrowing (clang -Wimplicit-float-conversion, GCC -Wfloat-conversion). n is already SCoordinate::Type (== TCoordinate), so forward it unchanged, and make the value's U -> T conversion explicit to document the intended narrowing (GCC -Wconversion / MSVC C4244). Behaviour is unchanged. Co-authored-by: Cursor --- include/maths/common/CBasicStatistics.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/maths/common/CBasicStatistics.h b/include/maths/common/CBasicStatistics.h index 5e89f41ecc..7bd0a1b53b 100644 --- a/include/maths/common/CBasicStatistics.h +++ b/include/maths/common/CBasicStatistics.h @@ -1420,7 +1420,12 @@ struct SCentralMomentsCustomAdd { static inline void add(const U& x, typename SCoordinate::Type n, CBasicStatistics::SSampleCentralMoments& moments) { - moments.add(x, static_cast(n), 0); + // n is already SCoordinate::Type (== the moments' TCoordinate), so + // pass it through unchanged; casting via double reintroduced a narrowing + // TCoordinate -> double -> TCoordinate for float coordinates. The value + // is stored as T, so make the U -> T conversion explicit here to + // document the intended narrowing (silences -Wconversion / MSVC C4244). + moments.add(static_cast(x), n, 0); } }; } From 63113d7bc26ad09ff8576097aa3e7347a781d2d8 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Thu, 30 Jul 2026 10:05:58 +1200 Subject: [PATCH 19/20] [ML] Replace deprecated boost::json::error_code with boost::system::error_code boost::json::error_code is a deprecated typedef alias for boost::system::error_code (Boost 1.86 marks it BOOST_JSON_DEPRECATED and removes it entirely in 1.87.0). Using it triggered ~1264 MSVC C4996 deprecation warnings. The two are the same type and boost::system::error_code is always transitively included wherever boost::json is used, so this is a type-identical swap that removes the warnings and future-proofs the code. Co-authored-by: Cursor --- bin/pytorch_inference/CCommandParser.cc | 2 +- include/api/CSerializableToJson.h | 6 +- include/core/CBoostJsonParser.h | 10 +-- include/core/CJsonStateRestoreTraverser.h | 38 ++++++----- include/core/CStateDecompressor.h | 54 +++++++-------- lib/api/CConfigUpdater.cc | 2 +- ...ataFrameAnalysisSpecificationJsonWriter.cc | 2 +- lib/api/CDetectionRulesJsonParser.cc | 2 +- lib/api/CNdJsonInputParser.cc | 2 +- lib/api/CRetrainableModelJsonReader.cc | 46 +++++++------ lib/api/CSerializableToJson.cc | 2 +- lib/api/unittest/CAnnotationJsonWriterTest.cc | 2 +- lib/api/unittest/CAnomalyJobLimitTest.cc | 2 +- lib/api/unittest/CAnomalyJobTest.cc | 4 +- .../CBoostedTreeInferenceModelBuilderTest.cc | 8 +-- .../CDataFrameAnalysisInstrumentationTest.cc | 8 +-- .../unittest/CDataFrameAnalysisRunnerTest.cc | 2 +- ...CDataFrameAnalyzerFeatureImportanceTest.cc | 8 +-- .../unittest/CDataFrameAnalyzerOutlierTest.cc | 16 ++--- .../CDataFrameAnalyzerTrainingTest.cc | 32 ++++----- ...ameTrainBoostedTreeClassifierRunnerTest.cc | 2 +- ...ameTrainBoostedTreeRegressionRunnerTest.cc | 2 +- .../CDataSummarizationJsonSerializerTest.cc | 2 +- lib/api/unittest/CForecastRunnerTest.cc | 8 +-- .../unittest/CInferenceModelMetadataTest.cc | 8 +-- lib/api/unittest/CJsonOutputWriterTest.cc | 34 +++++----- ...moryUsageEstimationResultJsonWriterTest.cc | 2 +- .../unittest/CModelPlotDataJsonWriterTest.cc | 2 +- .../unittest/CModelSnapshotJsonWriterTest.cc | 2 +- lib/api/unittest/CMultiFileDataAdderTest.cc | 2 +- lib/api/unittest/CResultNormalizerTest.cc | 4 +- lib/api/unittest/CSerializableToJsonTest.cc | 4 +- lib/core/CJsonStateRestoreTraverser.cc | 36 +++++----- lib/core/CStateDecompressor.cc | 68 +++++++++++-------- .../unittest/CJsonOutputStreamWrapperTest.cc | 2 +- lib/core/unittest/CLoggerTest.cc | 2 +- lib/model/unittest/CAnomalyScoreTest.cc | 2 +- 37 files changed, 221 insertions(+), 209 deletions(-) diff --git a/bin/pytorch_inference/CCommandParser.cc b/bin/pytorch_inference/CCommandParser.cc index a5a323dc49..ae98555a9b 100644 --- a/bin/pytorch_inference/CCommandParser.cc +++ b/bin/pytorch_inference/CCommandParser.cc @@ -47,7 +47,7 @@ bool CCommandParser::ioLoop(const TRequestHandlerFunc& requestHandler, json::value doc; json::stream_parser p; - json::error_code ec; + boost::system::error_code ec; std::string line; std::size_t n = 0; while (true) { diff --git a/include/api/CSerializableToJson.h b/include/api/CSerializableToJson.h index bfb0338c0f..3d154f9b47 100644 --- a/include/api/CSerializableToJson.h +++ b/include/api/CSerializableToJson.h @@ -131,7 +131,7 @@ class API_EXPORT CSerializableFromCompressedChunkedJson { TIStreamPtr inputStream, std::iostream& buffer); - static void assertNoParseError(const json::error_code& ec) { + static void assertNoParseError(const boost::system::error_code& ec) { if (ec) { throw std::runtime_error{"Error parsing JSON: " + ec.message()}; } @@ -178,7 +178,7 @@ class API_EXPORT CSerializableFromCompressedChunkedJson { } static std::int64_t getAsInt64From(const json::value& value) { - json::error_code ec; + boost::system::error_code ec; std::int64_t ret = value.to_number(ec); if (ec) { throw std::runtime_error{"is not a int64"}; @@ -187,7 +187,7 @@ class API_EXPORT CSerializableFromCompressedChunkedJson { } static std::uint64_t getAsUint64From(const json::value& value) { - json::error_code ec; + boost::system::error_code ec; std::uint64_t ret = value.to_number(ec); if (ec) { throw std::runtime_error{"is not a uint64"}; diff --git a/include/core/CBoostJsonParser.h b/include/core/CBoostJsonParser.h index c30242fc68..ca1f532708 100644 --- a/include/core/CBoostJsonParser.h +++ b/include/core/CBoostJsonParser.h @@ -40,7 +40,7 @@ class CORE_EXPORT CBoostJsonParser { static bool parse(const std::string& jsonString, json::value& doc) { unsigned char buffer[JSON_PARSE_BUFFER_SIZE]; // Small stack buffer to avoid most allocations during parse json::monotonic_resource mr(buffer); // This resource will use our local buffer first - json::error_code ec; + boost::system::error_code ec; doc = json::parse(jsonString, ec, &mr); if (ec) { LOG_ERROR(<< "An error occurred while parsing JSON: \"" @@ -50,14 +50,14 @@ class CORE_EXPORT CBoostJsonParser { return true; } - static json::error_code parse(std::istream& istream, json::value& doc) { + static boost::system::error_code parse(std::istream& istream, json::value& doc) { json::stream_parser p; unsigned char buf[JSON_PARSE_BUFFER_SIZE]; // Now we need a buffer to hold the actual JSON values json::monotonic_resource mr(buf); // The static resource is monotonic, using only a caller-provided buffer p.reset(&mr); // Use the static resource for producing the value - json::error_code ec; + boost::system::error_code ec; std::string line; while (std::getline(istream, line)) { LOG_TRACE(<< "write_some: " << line); @@ -70,14 +70,14 @@ class CORE_EXPORT CBoostJsonParser { return ec; } - static json::error_code parse(char* begin, std::size_t length, json::value& doc) { + static boost::system::error_code parse(char* begin, std::size_t length, json::value& doc) { json::stream_parser p; unsigned char buf[JSON_PARSE_BUFFER_SIZE]; // Now we need a buffer to hold the actual JSON values json::monotonic_resource mr(buf); // The static resource is monotonic, using only a caller-provided buffer p.reset(&mr); // Use the static resource for producing the value - json::error_code ec; + boost::system::error_code ec; std::size_t written{0}; p.reset(); while (written < length) { diff --git a/include/core/CJsonStateRestoreTraverser.h b/include/core/CJsonStateRestoreTraverser.h index 330bbff032..dab552f866 100644 --- a/include/core/CJsonStateRestoreTraverser.h +++ b/include/core/CJsonStateRestoreTraverser.h @@ -130,21 +130,23 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_document_begin(json::error_code& ec); + bool on_document_begin(boost::system::error_code& ec); //! Called when the JSON parsing is done. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_document_end(json::error_code& ec) { return ec ? false : true; } + bool on_document_end(boost::system::error_code& ec) { + return ec ? false : true; + } //! Called when the beginning of an array is encountered. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_array_begin(json::error_code& ec); + bool on_array_begin(boost::system::error_code& ec); //! Called when the end of the current array is encountered. //! @@ -152,14 +154,14 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param n The number of elements in the array. //! @param ec Set to the error, if any occurred. //! - bool on_array_end(std::size_t n, json::error_code& ec); + bool on_array_end(std::size_t n, boost::system::error_code& ec); //! Called when the beginning of an object is encountered. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_object_begin(json::error_code& ec); + bool on_object_begin(boost::system::error_code& ec); //! Called when the end of the current object is encountered. //! @@ -167,7 +169,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param n The number of elements in the object. //! @param ec Set to the error, if any occurred. //! - bool on_object_end(std::size_t n, json::error_code& ec); + bool on_object_end(std::size_t n, boost::system::error_code& ec); //! Called with characters corresponding to part of the current string. //! @@ -176,7 +178,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param n The total size of the string thus far //! @param ec Set to the error, if any occurred. //! - bool on_string_part(std::string_view s, std::size_t n, json::error_code& ec); + bool on_string_part(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with the last characters corresponding to the current string. //! @@ -185,7 +187,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param n The total size of the string //! @param ec Set to the error, if any occurred. //! - bool on_string(std::string_view s, std::size_t n, json::error_code& ec); + bool on_string(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with characters corresponding to part of the current key. //! @@ -194,7 +196,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param n The total size of the key thus far //! @param ec Set to the error, if any occurred. //! - bool on_key_part(std::string_view s, std::size_t n, json::error_code& ec); + bool on_key_part(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with the last characters corresponding to the current key. //! @@ -203,7 +205,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param n The total size of the key //! @param ec Set to the error, if any occurred. //! - bool on_key(std::string_view s, std::size_t n, json::error_code& ec); + bool on_key(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with the characters corresponding to part of the current number. //! @@ -211,7 +213,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param s The partial characters //! @param ec Set to the error, if any occurred. //! - bool on_number_part(std::string_view s, json::error_code& ec); + bool on_number_part(std::string_view s, boost::system::error_code& ec); //! Called when a signed integer is parsed. //! @@ -220,7 +222,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_int64(int64_t i, std::string_view s, json::error_code& ec); + bool on_int64(int64_t i, std::string_view s, boost::system::error_code& ec); //! Called when an unsigend integer is parsed. //! @@ -229,7 +231,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_uint64(uint64_t u, std::string_view s, json::error_code& ec); + bool on_uint64(uint64_t u, std::string_view s, boost::system::error_code& ec); //! Called when a double is parsed. //! @@ -238,7 +240,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_double(double d, std::string_view s, json::error_code& ec); + bool on_double(double d, std::string_view s, boost::system::error_code& ec); //! Called when a boolean is parsed. //! @@ -246,14 +248,14 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param b The value //! @param ec Set to the error, if any occurred. //! - bool on_bool(bool b, json::error_code& ec); + bool on_bool(bool b, boost::system::error_code& ec); //! Called when a null is parsed. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_null(json::error_code& ec); + bool on_null(boost::system::error_code& ec); //! Called with characters corresponding to part of the current comment. //! @@ -261,7 +263,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param s The partial characters. //! @param ec Set to the error, if any occurred. //! - bool on_comment_part(std::string_view s, json::error_code& ec); + bool on_comment_part(std::string_view s, boost::system::error_code& ec); //! Called with the last characters corresponding to the current comment. //! @@ -269,7 +271,7 @@ class CORE_EXPORT CJsonStateRestoreTraverser : public CStateRestoreTraverser { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_comment(std::string_view s, json::error_code& ec); + bool on_comment(std::string_view s, boost::system::error_code& ec); enum ETokenType { E_TokenNull = 0, diff --git a/include/core/CStateDecompressor.h b/include/core/CStateDecompressor.h index 6de8a414ae..0b281df23c 100644 --- a/include/core/CStateDecompressor.h +++ b/include/core/CStateDecompressor.h @@ -111,21 +111,21 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_document_begin(json::error_code& ec); + bool on_document_begin(boost::system::error_code& ec); //! Called when the JSON parsing is done. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_document_end(json::error_code& ec); + bool on_document_end(boost::system::error_code& ec); //! Called when the beginning of an array is encountered. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_array_begin(json::error_code& ec); + bool on_array_begin(boost::system::error_code& ec); //! Called when the end of the current array is encountered. //! @@ -133,14 +133,14 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param n The number of elements in the array. //! @param ec Set to the error, if any occurred. //! - bool on_array_end(std::size_t n, json::error_code& ec); + bool on_array_end(std::size_t n, boost::system::error_code& ec); //! Called when the beginning of an object is encountered. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_object_begin(json::error_code& ec); + bool on_object_begin(boost::system::error_code& ec); //! Called when the end of the current object is encountered. //! @@ -148,7 +148,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param n The number of elements in the object. //! @param ec Set to the error, if any occurred. //! - bool on_object_end(std::size_t n, json::error_code& ec); + bool on_object_end(std::size_t n, boost::system::error_code& ec); //! Called with characters corresponding to part of the current string. //! @@ -157,7 +157,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param n The total size of the string thus far //! @param ec Set to the error, if any occurred. //! - bool on_string_part(std::string_view s, std::size_t n, json::error_code& ec); + bool on_string_part(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with the last characters corresponding to the current string. //! @@ -166,7 +166,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param n The total size of the string //! @param ec Set to the error, if any occurred. //! - bool on_string(std::string_view s, std::size_t n, json::error_code& ec); + bool on_string(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with characters corresponding to part of the current key. //! @@ -175,7 +175,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param n The total size of the key thus far //! @param ec Set to the error, if any occurred. //! - bool on_key_part(std::string_view s, std::size_t n, json::error_code& ec); + bool on_key_part(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with the last characters corresponding to the current key. //! @@ -184,7 +184,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param n The total size of the key //! @param ec Set to the error, if any occurred. //! - bool on_key(std::string_view s, std::size_t n, json::error_code& ec); + bool on_key(std::string_view s, std::size_t n, boost::system::error_code& ec); //! Called with the characters corresponding to part of the current number. //! @@ -192,7 +192,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param s The partial characters //! @param ec Set to the error, if any occurred. //! - bool on_number_part(std::string_view s, json::error_code& ec); + bool on_number_part(std::string_view s, boost::system::error_code& ec); //! Called when a signed integer is parsed. //! @@ -201,7 +201,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_int64(int64_t i, std::string_view s, json::error_code& ec); + bool on_int64(int64_t i, std::string_view s, boost::system::error_code& ec); //! Called when an unsigend integer is parsed. //! @@ -210,7 +210,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_uint64(uint64_t u, std::string_view s, json::error_code& ec); + bool on_uint64(uint64_t u, std::string_view s, boost::system::error_code& ec); //! Called when a double is parsed. //! @@ -219,7 +219,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_double(double d, std::string_view s, json::error_code& ec); + bool on_double(double d, std::string_view s, boost::system::error_code& ec); //! Called when a boolean is parsed. //! @@ -227,14 +227,14 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param b The value //! @param ec Set to the error, if any occurred. //! - bool on_bool(bool b, json::error_code& ec); + bool on_bool(bool b, boost::system::error_code& ec); //! Called when a null is parsed. //! //! @return `true` on success. //! @param ec Set to the error, if any occurred. //! - bool on_null(json::error_code& ec); + bool on_null(boost::system::error_code& ec); //! Called with characters corresponding to part of the current comment. //! @@ -242,7 +242,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param s The partial characters. //! @param ec Set to the error, if any occurred. //! - bool on_comment_part(std::string_view s, json::error_code& ec); + bool on_comment_part(std::string_view s, boost::system::error_code& ec); //! Called with the last characters corresponding to the current comment. //! @@ -250,7 +250,7 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { //! @param s The remaining characters //! @param ec Set to the error, if any occurred. //! - bool on_comment(std::string_view s, json::error_code& ec); + bool on_comment(std::string_view s, boost::system::error_code& ec); size_t s_Level[2]; bool s_IsEndOfLevel[2]; @@ -266,15 +266,15 @@ class CORE_EXPORT CStateDecompressor : public CDataSearcher { struct SBoostJsonHandler final : public SBaseBoostJsonHandler { - bool on_bool(bool b, json::error_code& ec); - bool on_string(std::string_view s, std::size_t n, json::error_code& ec); - bool on_string_part(std::string_view s, std::size_t n, json::error_code& ec); - bool on_object_begin(json::error_code& ec); - bool on_key(std::string_view s, std::size_t n, json::error_code& ec); - bool on_key_part(std::string_view s, std::size_t n, json::error_code& ec); - bool on_object_end(std::size_t n, json::error_code& ec); - bool on_array_begin(json::error_code& ec); - bool on_array_end(std::size_t n, json::error_code& ec); + bool on_bool(bool b, boost::system::error_code& ec); + bool on_string(std::string_view s, std::size_t n, boost::system::error_code& ec); + bool on_string_part(std::string_view s, std::size_t n, boost::system::error_code& ec); + bool on_object_begin(boost::system::error_code& ec); + bool on_key(std::string_view s, std::size_t n, boost::system::error_code& ec); + bool on_key_part(std::string_view s, std::size_t n, boost::system::error_code& ec); + bool on_object_end(std::size_t n, boost::system::error_code& ec); + bool on_array_begin(boost::system::error_code& ec); + bool on_array_end(std::size_t n, boost::system::error_code& ec); enum ETokenType { ETokenNull = 0, diff --git a/lib/api/CConfigUpdater.cc b/lib/api/CConfigUpdater.cc index fb045d3549..9e676628b6 100644 --- a/lib/api/CConfigUpdater.cc +++ b/lib/api/CConfigUpdater.cc @@ -26,7 +26,7 @@ CConfigUpdater::CConfigUpdater(CAnomalyJobConfig& jobConfig, bool CConfigUpdater::update(const std::string& json) { json::parser p; - json::error_code ec; + boost::system::error_code ec; p.write_some(json, ec); if (ec) { LOG_ERROR(<< "An error occurred while parsing pattern set from JSON: " diff --git a/lib/api/CDataFrameAnalysisSpecificationJsonWriter.cc b/lib/api/CDataFrameAnalysisSpecificationJsonWriter.cc index 48c3828ed0..3d9e5e0852 100644 --- a/lib/api/CDataFrameAnalysisSpecificationJsonWriter.cc +++ b/lib/api/CDataFrameAnalysisSpecificationJsonWriter.cc @@ -35,7 +35,7 @@ void CDataFrameAnalysisSpecificationJsonWriter::write(const std::string& jobId, TBoostJsonLineWriter& writer) { json::value analysisParametersDoc; if (analysisParameters.empty() == false) { - json::error_code ec; + boost::system::error_code ec; json::parser p; p.write(analysisParameters, ec); if (ec.failed()) { diff --git a/lib/api/CDetectionRulesJsonParser.cc b/lib/api/CDetectionRulesJsonParser.cc index f2bb7797a3..3985b0db40 100644 --- a/lib/api/CDetectionRulesJsonParser.cc +++ b/lib/api/CDetectionRulesJsonParser.cc @@ -100,7 +100,7 @@ bool CDetectionRulesJsonParser::parseRules(const std::string& json, TDetectionRu LOG_DEBUG(<< "Parsing detection rules"); rules.clear(); - json::error_code ec; + boost::system::error_code ec; json::parser p; p.write(json, ec); if (ec) { diff --git a/lib/api/CNdJsonInputParser.cc b/lib/api/CNdJsonInputParser.cc index 151d25538f..16bf088005 100644 --- a/lib/api/CNdJsonInputParser.cc +++ b/lib/api/CNdJsonInputParser.cc @@ -118,7 +118,7 @@ bool CNdJsonInputParser::readStreamIntoVecs(const TVecReaderFunc& readerFunc, bool CNdJsonInputParser::parseDocument(char* begin, std::size_t length, json::value& document) { // Parse JSON string - json::error_code ec = core::CBoostJsonParser::parse(begin, length, document); + boost::system::error_code ec = core::CBoostJsonParser::parse(begin, length, document); if (ec) { LOG_ERROR(<< "JSON parse error: " << ec.message()); return false; diff --git a/lib/api/CRetrainableModelJsonReader.cc b/lib/api/CRetrainableModelJsonReader.cc index fb47911af0..de215a04d7 100644 --- a/lib/api/CRetrainableModelJsonReader.cc +++ b/lib/api/CRetrainableModelJsonReader.cc @@ -58,13 +58,13 @@ class custom_parser { constexpr static std::size_t max_string_size = ml::core::boost_json_constants::MAX_STRING_SIZE; - bool on_document_begin(json::error_code&) { + bool on_document_begin(boost::system::error_code&) { s_Value.emplace_object(); s_CurrentValue.push(&s_Value); return true; } - bool on_document_end(json::error_code&) { return true; } - bool on_object_begin(json::error_code&) { + bool on_document_end(boost::system::error_code&) { return true; } + bool on_object_begin(boost::system::error_code&) { LOG_TRACE(<< "on_object_begin: s_Depth = " << s_CurrentValue.size()); if (s_Keys.empty() == false) { if (s_Keys.top() == "encoding_vector") { @@ -84,7 +84,7 @@ class custom_parser { } return true; } - bool on_object_end(std::size_t, json::error_code&) { + bool on_object_end(std::size_t, boost::system::error_code&) { LOG_TRACE(<< "on_object_end: s_Depth = " << s_CurrentValue.size()); s_CurrentValue.pop(); if (s_Keys.empty() == false && s_EncodingTags.count(s_Keys.top()) > 0) { @@ -96,7 +96,7 @@ class custom_parser { } return true; } - bool on_array_begin(json::error_code&) { + bool on_array_begin(boost::system::error_code&) { LOG_TRACE(<< "on_array_begin: s_Depth = " << s_CurrentValue.size()); if (s_CurrentValue.empty() == false) { if (s_CurrentValue.top()->is_array()) { @@ -111,7 +111,7 @@ class custom_parser { return true; } - bool on_array_end(std::size_t, json::error_code&) { + bool on_array_end(std::size_t, boost::system::error_code&) { LOG_TRACE(<< "on_array_end: s_Depth = " << s_CurrentValue.size()); s_CurrentValue.pop(); @@ -120,10 +120,10 @@ class custom_parser { } return true; } - bool on_key_part(std::string_view, std::size_t, json::error_code&) { + bool on_key_part(std::string_view, std::size_t, boost::system::error_code&) { return true; } - bool on_key(std::string_view s, std::size_t /*n*/, json::error_code& ec) { + bool on_key(std::string_view s, std::size_t /*n*/, boost::system::error_code& ec) { std::string str{s}; s_Keys.push(str); if (s_CurrentValue.top()->is_array()) { @@ -132,10 +132,10 @@ class custom_parser { } return ec ? false : true; } - bool on_string_part(std::string_view, std::size_t, json::error_code&) { + bool on_string_part(std::string_view, std::size_t, boost::system::error_code&) { return true; } - bool on_string(std::string_view s, std::size_t /*n*/, json::error_code& ec) { + bool on_string(std::string_view s, std::size_t /*n*/, boost::system::error_code& ec) { if (s_CurrentValue.top()->is_array()) { s_CurrentValue.top()->as_array().push_back(json::string(s)); } else { @@ -149,10 +149,10 @@ class custom_parser { } return ec ? false : true; } - bool on_number_part(std::string_view, json::error_code&) { + bool on_number_part(std::string_view, boost::system::error_code&) { return true; } - bool on_int64(std::int64_t i, std::string_view, json::error_code& ec) { + bool on_int64(std::int64_t i, std::string_view, boost::system::error_code& ec) { LOG_TRACE(<< "on_int64: " << i); if (s_CurrentValue.top()->is_array()) { s_CurrentValue.top()->as_array().push_back(json::value(i)); @@ -164,7 +164,7 @@ class custom_parser { } return ec ? false : true; } - bool on_uint64(std::uint64_t u, std::string_view, json::error_code& ec) { + bool on_uint64(std::uint64_t u, std::string_view, boost::system::error_code& ec) { LOG_TRACE(<< "on_uint64: " << u); if (s_CurrentValue.top()->is_array()) { s_CurrentValue.top()->as_array().push_back(json::value(u)); @@ -176,7 +176,7 @@ class custom_parser { } return ec ? false : true; } - bool on_double(double d, std::string_view, json::error_code& ec) { + bool on_double(double d, std::string_view, boost::system::error_code& ec) { LOG_TRACE(<< "on_double: " << d); if (s_CurrentValue.top()->is_array()) { s_CurrentValue.top()->as_array().push_back(json::value(d)); @@ -188,7 +188,7 @@ class custom_parser { } return ec ? false : true; } - bool on_bool(bool b, json::error_code& ec) { + bool on_bool(bool b, boost::system::error_code& ec) { LOG_TRACE(<< "on_bool: " << b); if (s_CurrentValue.top()->is_array()) { s_CurrentValue.top()->as_array().push_back(json::value(b)); @@ -200,14 +200,16 @@ class custom_parser { } return ec ? false : true; } - bool on_null(json::error_code&) { + bool on_null(boost::system::error_code&) { LOG_TRACE(<< "on_null: "); return true; } - bool on_comment_part(std::string_view, json::error_code&) { + bool on_comment_part(std::string_view, boost::system::error_code&) { + return true; + } + bool on_comment(std::string_view, boost::system::error_code&) { return true; } - bool on_comment(std::string_view, json::error_code&) { return true; } std::stack s_Keys; json::value s_Value; @@ -224,7 +226,7 @@ class custom_parser { ~custom_parser() {} - std::size_t write(char const* data, std::size_t size, json::error_code& ec) { + std::size_t write(char const* data, std::size_t size, boost::system::error_code& ec) { auto const n = p_.write_some(false, data, size, ec); if (!ec && n < size) ec = json::error::extra_data; @@ -234,7 +236,7 @@ class custom_parser { json::value release() const { return std::move(p_.handler().s_Value); } }; -bool parse(std::string_view s, json::value& value, json::error_code& ec) { +bool parse(std::string_view s, json::value& value, boost::system::error_code& ec) { // Parse with the custom parser and return false on error custom_parser p; p.write(s.data(), s.size(), ec); @@ -283,7 +285,7 @@ CRetrainableModelJsonReader::TEncoderUPtrStrSizeUMapPr CRetrainableModelJsonReader::doDataSummarizationFromJsonStream(std::istream& istream, core::CDataFrame& frame) { json::value doc; - json::error_code ec; + boost::system::error_code ec; std::string line; while (std::getline(istream, line) && !ec) { LOG_TRACE(<< "Parsing line: " << line); @@ -386,7 +388,7 @@ CRetrainableModelJsonReader::doBestForestFromJsonStream(std::istream& istream, using TNodeVecVec = maths::analytics::CBoostedTreeFactory::TNodeVecVec; json::value doc; - json::error_code ec = core::CBoostJsonParser::parse(istream, doc); + boost::system::error_code ec = core::CBoostJsonParser::parse(istream, doc); assertNoParseError(ec); assertIsJsonObject(doc); diff --git a/lib/api/CSerializableToJson.cc b/lib/api/CSerializableToJson.cc index ac00e7e181..8fde1ad7ec 100644 --- a/lib/api/CSerializableToJson.cc +++ b/lib/api/CSerializableToJson.cc @@ -140,7 +140,7 @@ CSerializableFromCompressedChunkedJson::rawJsonStream(const std::string& compres std::string line; std::getline(*inputStream, line); json::value doc; - json::error_code ec = + boost::system::error_code ec = core::CBoostJsonParser::parse(line.data(), line.length(), doc); assertNoParseError(ec); diff --git a/lib/api/unittest/CAnnotationJsonWriterTest.cc b/lib/api/unittest/CAnnotationJsonWriterTest.cc index a3d792a747..0b5d21f972 100644 --- a/lib/api/unittest/CAnnotationJsonWriterTest.cc +++ b/lib/api/unittest/CAnnotationJsonWriterTest.cc @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(testWrite) { } LOG_DEBUG(<< "annotation: " << sstream.str()); - json::error_code ec; + boost::system::error_code ec; json::value jv = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(jv.is_array()); diff --git a/lib/api/unittest/CAnomalyJobLimitTest.cc b/lib/api/unittest/CAnomalyJobLimitTest.cc index e4cffde084..e1b7feae4c 100644 --- a/lib/api/unittest/CAnomalyJobLimitTest.cc +++ b/lib/api/unittest/CAnomalyJobLimitTest.cc @@ -42,7 +42,7 @@ using namespace ml; std::set getUniqueValues(const std::string& key, const std::string& output) { std::set values; - json::error_code ec; + boost::system::error_code ec; LOG_DEBUG(<< "Parsing: [ " << output << " ]"); json::value doc = json::parse(output, ec); BOOST_TEST_REQUIRE(ec.failed() == false); diff --git a/lib/api/unittest/CAnomalyJobTest.cc b/lib/api/unittest/CAnomalyJobTest.cc index 7bfc25d3a9..bc603bb860 100644 --- a/lib/api/unittest/CAnomalyJobTest.cc +++ b/lib/api/unittest/CAnomalyJobTest.cc @@ -157,7 +157,7 @@ class CResultsScoreVisitor : public ml::model::CHierarchicalResultsVisitor { size_t countBuckets(const std::string& key, const std::string& output) { size_t count = 0; - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output, ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -477,7 +477,7 @@ BOOST_AUTO_TEST_CASE(testControlMessages) { } } - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(outputStrm.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); diff --git a/lib/api/unittest/CBoostedTreeInferenceModelBuilderTest.cc b/lib/api/unittest/CBoostedTreeInferenceModelBuilderTest.cc index b04d9c34b9..debf57700c 100644 --- a/lib/api/unittest/CBoostedTreeInferenceModelBuilderTest.cc +++ b/lib/api/unittest/CBoostedTreeInferenceModelBuilderTest.cc @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(testIntegrationRegression) { values[2].push_back(values[0][i] * weights[0] + values[1][i] * weights[1]); } - json::error_code ec; + boost::system::error_code ec; json::value customProcessors = json::parse( "[{\"special_processor\":{\"foo\": 42}}, {\"another_special_processor\":{\"foo\": \"Column_foo\", \"field\": \"bar\"}}]", ec); @@ -393,7 +393,7 @@ BOOST_AUTO_TEST_CASE(testIntegrationClassification) { values[1] = generateCategoricalData(rng, numberExamples, {100., 5.0, 5.0}).second; values[2] = generateCategoricalData(rng, numberExamples, {5.0, 5.0}).second; - json::error_code ec; + boost::system::error_code ec; json::value customProcessors = json::parse( "[{\"special_processor\":{\"foo\": 43}}, {\"another_special\":{\"foo\": \"Column_foo\", \"field\": \"bar\"}}]", ec); @@ -630,7 +630,7 @@ BOOST_AUTO_TEST_CASE(testJsonSchema) { valijson::adapters::BoostJsonAdapter schemaAdapter(schemaDocument); parser.populateSchema(schemaAdapter, schema); - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(definition->jsonString(), ec); BOOST_REQUIRE_MESSAGE(ec.failed() == false, "Error parsing JSON definition!"); @@ -666,7 +666,7 @@ BOOST_AUTO_TEST_CASE(testJsonSchema) { valijson::adapters::BoostJsonAdapter schemaAdapter(schemaDocument); parser.populateSchema(schemaAdapter, schema); - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(definition->sizeInfo()->jsonString(), ec); BOOST_REQUIRE_MESSAGE(ec.failed() == false, "Error parsing JSON size info!"); diff --git a/lib/api/unittest/CDataFrameAnalysisInstrumentationTest.cc b/lib/api/unittest/CDataFrameAnalysisInstrumentationTest.cc index 4fdc151fb9..bbbf36c83c 100644 --- a/lib/api/unittest/CDataFrameAnalysisInstrumentationTest.cc +++ b/lib/api/unittest/CDataFrameAnalysisInstrumentationTest.cc @@ -134,7 +134,7 @@ BOOST_FIXTURE_TEST_CASE(testMemoryState, ml::test::CProgramCounterClearingFixtur .count()}; json::value results; - json::error_code ec; + boost::system::error_code ec; json::parser p; std::size_t written = p.write(outputStream.str(), ec); BOOST_TEST_REQUIRE(outputStream.str().size() == written); @@ -186,7 +186,7 @@ BOOST_FIXTURE_TEST_CASE(testTrainingRegression, ml::test::CProgramCounterClearin analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); @@ -307,7 +307,7 @@ BOOST_FIXTURE_TEST_CASE(testTrainingClassification, ml::test::CProgramCounterCle analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); @@ -382,7 +382,7 @@ BOOST_FIXTURE_TEST_CASE(testOutlierDetection, ml::test::CProgramCounterClearingF expectedFeatureInfluences); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); diff --git a/lib/api/unittest/CDataFrameAnalysisRunnerTest.cc b/lib/api/unittest/CDataFrameAnalysisRunnerTest.cc index 02b1122b5a..127bcceab1 100644 --- a/lib/api/unittest/CDataFrameAnalysisRunnerTest.cc +++ b/lib/api/unittest/CDataFrameAnalysisRunnerTest.cc @@ -164,7 +164,7 @@ void testEstimateMemoryUsage(std::int64_t numberRows, spec->estimateMemoryUsage(writer); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); diff --git a/lib/api/unittest/CDataFrameAnalyzerFeatureImportanceTest.cc b/lib/api/unittest/CDataFrameAnalyzerFeatureImportanceTest.cc index c2860f16c6..9f5f3231d9 100644 --- a/lib/api/unittest/CDataFrameAnalyzerFeatureImportanceTest.cc +++ b/lib/api/unittest/CDataFrameAnalyzerFeatureImportanceTest.cc @@ -244,7 +244,7 @@ struct SFixture { BOOST_TEST_REQUIRE( core::CProgramCounters::counter(counter_t::E_DFTPMPeakMemoryUsage) < core::CProgramCounters::counter(counter_t::E_DFTPMEstimatedPeakMemoryUsage)); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(s_Output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -297,7 +297,7 @@ struct SFixture { core::CProgramCounters::counter(counter_t::E_DFTPMPeakMemoryUsage) < core::CProgramCounters::counter(counter_t::E_DFTPMEstimatedPeakMemoryUsage)); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(s_Output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -353,7 +353,7 @@ struct SFixture { core::CProgramCounters::counter(counter_t::E_DFTPMPeakMemoryUsage) < core::CProgramCounters::counter(counter_t::E_DFTPMEstimatedPeakMemoryUsage)); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(s_Output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); return std::make_pair(std::move(results), s_Output.str()); @@ -399,7 +399,7 @@ struct SFixture { core::CProgramCounters::counter(counter_t::E_DFTPMPeakMemoryUsage) < core::CProgramCounters::counter(counter_t::E_DFTPMEstimatedPeakMemoryUsage)); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(s_Output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); return results; diff --git a/lib/api/unittest/CDataFrameAnalyzerOutlierTest.cc b/lib/api/unittest/CDataFrameAnalyzerOutlierTest.cc index ee12b45ac2..8338e48ece 100644 --- a/lib/api/unittest/CDataFrameAnalyzerOutlierTest.cc +++ b/lib/api/unittest/CDataFrameAnalyzerOutlierTest.cc @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(testWithoutControlMessages) { analyzer.receivedAllRows(); analyzer.run(); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(testRunOutlierDetection) { expectedFeatureInfluences); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -267,7 +267,7 @@ BOOST_AUTO_TEST_CASE(testRunOutlierDetectionPartitioned) { expectedFeatureInfluences, 990, 10); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(testRunOutlierFeatureInfluences) { maths::analytics::COutliers::E_Ensemble, 0, true); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE(testRunOutlierDetectionWithParams) { expectedFeatureInfluences, 100, 10, method, k); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -622,7 +622,7 @@ BOOST_AUTO_TEST_CASE(testErrors) { BOOST_TEST_REQUIRE(memoryLimitExceed); // verify memory status change - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -672,7 +672,7 @@ BOOST_AUTO_TEST_CASE(testRoundTripDocHashes) { analyzer.handleRecord({"c1", "c2", "c3", "c4", "c5", ".", "."}, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -714,7 +714,7 @@ BOOST_AUTO_TEST_CASE(testProgress) { expectedFeatureInfluences); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); diff --git a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc index 04e9696ff9..0fc979641a 100644 --- a/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc +++ b/lib/api/unittest/CDataFrameAnalyzerTrainingTest.cc @@ -109,7 +109,7 @@ json::object treeToJsonDocument(const maths::analytics::CBoostedTree& tree) { tree.acceptPersistInserter(inserter); persistStream.flush(); } - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(persistStream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_object()); @@ -306,7 +306,7 @@ void testRegressionTrainingWithParams(TLossFunctionType lossFunction) { BOOST_TEST_REQUIRE(hyperparameters.softTreeDepthLimit().value() == softTreeDepthLimit); BOOST_TEST_REQUIRE(hyperparameters.softTreeDepthTolerance().value() == softTreeDepthTolerance); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); @@ -353,7 +353,7 @@ void readIncrementalTrainingState(const std::string& resultsJson, double& lossGap, std::ostream& incrementalTrainingState) { - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(resultsJson, ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -428,7 +428,7 @@ void readIncrementalTrainingState(const std::string& resultsJson, void readIncrementalTrainingState(const std::string& resultsJson, std::ostream& incrementalTrainingState) { - json::error_code ec; + boost::system::error_code ec; // std::string str = "[{\"analytics_memory_usage\":{\"job_id\":\"testJob\",\"timestamp\":1704805891956,\"peak_usage_bytes\":4032,\"status\":\"ok\"}}\n,{\"analytics_memory_usage\":{\"job_id\":\"testJob\",\"timestamp\":1704805893487,\"peak_usage_bytes\":4272,\"status\":\"ok\"}}\n,{\"phase_progress\":{\"phase\":\"feature_selection\",\"progress_percent\":0}}\n,{\"phase_progress\":{\"phase\":\"feature_selection\",\"progress_percent\":1}}\n,{\"analytics_memory_usage\":{\"job_id\":\"testJob\",\"timestamp\":1704805893525,\"peak_usage_bytes\":4752,\"status\":\"ok\"}}\n,{\"analytics_memory_usage\":{\"job_id\":\"testJob\",\"timestamp\":1704805893526,\"peak_usage_bytes\":9092,\"status\":\"ok\"}}\n,{\"phase_progress\":{\"phase\":\"feature_selection\",\"progress_percent\":100}}\n,{\"phase_progress\":{\"phase\":\"coarse_parameter_search\",\"progress_percent\":0}}\n,{\"phase_progress\":{\"phase\":\"coarse_parameter_search\",\"progress_percent\":1}}\n,{\"phase_progress\":{\"phase\":\"coarse_parameter_search\",\"progress_percent\":4}}\n,{\"phase_progress\":{\"phase\":\"coarse_parameter_search\",\"progress_percent\":5}}\n,{\"phase_progress\":{\"phase\":\"coarse_parameter_search\",\"progress_percent\":8}}\n,{\"phase_progress\":{\"phase\":\"coarse_parameter_search\",\"progress_percent\":100}}\n,{\"phase_progress\":{\"phase\":\"fine_tuning_parameters\",\"progress_percent\":100}}\n,{\"analytics_memory_usage\":{\"job_id\":\"testJob\",\"timestamp\":1704805923077,\"peak_usage_bytes\":235303,\"status\":\"ok\"},\"regression_stats\":{\"job_id\":\"testJob\",\"timestamp\":1704805923077,\"iteration\":0,\"hyperparameters\":{\"eta\":0.3805847,\"alpha\":7.102547,\"soft_tree_depth_limit\":9.228819,\"soft_tree_depth_tolerance\":0.15,\"gamma\":0.02713613,\"lambda\":0.7970777,\"downsample_factor\":0.3423561,\"num_folds\":0,\"max_trees\":10,\"feature_bag_fraction\":0.4,\"eta_growth_rate_per_tree\":1.190292,\"max_attempts_to_add_tree\":0,\"num_splits_per_feature\":0,\"max_optimization_rounds_per_hyperparameter\":2},\"validation_loss\":{\"loss_type\":\"mse\",\"fold_values\":[]},\"timing_stats\":{\"elapsed_time\":0,\"iteration_time\":0}}}\n,{\"phase_progress\":{\"phase\":\"final_training\",\"progress_percent\":100}}\n,{\"phase_progress\":{\"phase\":\"final_training\",\"progress_percent\":100}}\n,{\"model_size_info\":{\"preprocessors\":[],\"trained_model_size\":{\"ensemble_model_size\":{\"feature_name_lengths\":[2,2,2,2],\"tree_sizes\":[{\"num_nodes\":0,\"num_leaves\":1},{\"num_nodes\":8,\"num_leaves\":9},{\"num_nodes\":10,\"num_leaves\":11},{\"num_nodes\":10,\"num_leaves\":11},{\"num_nodes\":6,\"num_leaves\":7},{\"num_nodes\":6,\"num_leaves\":7},{\"num_nodes\":8,\"num_leaves\":9},{\"num_nodes\":7,\"num_leaves\":8},{\"num_nodes\":9,\"num_leaves\":10},{\"num_nodes\":4,\"num_leaves\":5},{\"num_nodes\":7,\"num_leaves\":8}],\"num_output_processor_weights\":11,\"num_operations\":46}}}}\n,{\"compressed_inference_model\":{\"doc_num\":0,\"definition\":\"H4sIAAAAAAAA/81c224cOQ5938/oZ6cgUiQl+lcWg4bHrjgGfEO7vRcE+felnNnZtMhAtZppexzASAyrmipRh+ccUfm6ez6sz4en6/Xl5enwsrv8+y8Xu+Ph6u5xvdk/PN2s97vLr7v18WV9+PV+bX//vF4dXw/r/vHqYW2/v7uG3cXuGtu33L7Rrj3i6nC7HvfHfz/boN1hvT3YB9w9Pe66p7cnfLUfreGzRw9a1/3L8fB63Qa9PejRnrm/e7xZ/7W7TBe7x9eHX9fD/uXq4fm+PbDYz+7Xq8/7f1zdv9qItFAlJoVvv3z7dvHzOH6bYx7ObCagl+f7u+P+t498+63vP7m117S7ROWFsJI9/Yt90pen+5vd5SdYilJOerG7WT9fvd4f9/fr5+Pu0j57bT+7vmsh/TfI++OuzfvzcX/95a6Nh4vd4e72y+//xjb5H0MFH2qGYai0JM3lNFJZgBLAZKDcBSp9oBgEqi5QOA1U0wLIgqeR5gUAlXAy1NyFSn2o2Yfa3suP+fgJF0zIya0H+bFYh+uBliWlwMk06yJSVfLkLLWbJaQ+VA6m6bO8WxHCRbXKSaS0QM6gdTLS0kVa+0AleKfdesACJYuUfmjxQ3k0RcgLSUbqtwdLBZydJPQ7GVzq1DDWH2eJi9Qk3A/U4P3k0SzFUg4hnW6tvDCJ4CwIQL+1wO0tCLB1uCK8cLXl1dMVwQUS5zILA9BDFjjMggBdsQOCtKSUE5Gon2uEeW44VQFN6gZHKERudNUsXFzeQ4BD6gYjJU3BGkXI4AYDCXJxyQjBbqW+mDMUss8eFvP8O2GBD6joBihW0UX6ig4G1TQNBBMVHWW0Q6qlYS50ukOsqkiuOLtBZko60RBdU7a8K7WrIJos+tlaN1PRA5aEXaSwKPJpoJ/KUishyfnKQLBzwaM5OkanhtunlM4y1aCJy7nqcgQTw0zFBnipp3Rqr7oqzyYA9LHCFhIxZjtGBTRRC+uHYHnRYtBHZyNmAWkpjgikZGR9A4UQh73VeGvKG0iE38s9b13Inialp+fCCWR6i/QvCN0LikiEm2culvz+FUU1PfdjISUR8lU1QLyA3fc40rA5YC+1quK0MNxAtSIG4aaqpbJ6HRMRCBgSNVqq2LS4x0wyDaezOLSFqAVQ5BcVyJSLX9QIGTzLs7FEHq0h2KyeKxVi2yaeKwX7FdgpTcipotuwENF+55okfnNN+sodbCA/5Zwz5SpDlkbfCdoH+S4geakZTuWacVtQi35aycz4LkPNVRZlVjhFAlkUpMh7srRm/QwdCZSaueOTKfM0nZwhad4gQgc4XJmoZ5OqaXrtxwV6m8nTcwmD2lIrdqHaC9V5MTGmkwEy4vC1muAGrJ2XacsvpGm2rs/YPJ6BdIEawgFRzaeR6pKKMPP5Ck6E+sNNBUu2xOw2lenJTJYZ03RpTASiKuPRHo2MiCcCQZUZcvxGoMCqlieGQpZW70sMPSqnPlosqULGroJIYy3zW3MsSUJ7yRmbJbOR0S1UtPg1pZJrQJc2MEPLS3snlppbmKH3pSRpM4gmiNobXbL37n3OkKm5wQyUEP3gTUSNmO2jNxE1z7WyVAze1xae1uixOIoX0TT/qrFA1vpX99Jw4QIdSzNlIAyapoF6gqV5lHYGBXJBkN7+hySFzif6g/0sW2yfDKIdzrLxtHnqO3U8tgFkkymgmgQ6iyoXlmkvZc5O4/FZ7lJqTt755UJ6NqIe2Wl+t3OuBm9ucACN2ddpT/NqLp1raGoqkcCsFTekeQEO90XPsFQkSd3EZHq9bIDIaKrACf0xDr8dKWXMHv/jU6vuc5udo5uqPPfzLZg2+k3VGTiatBk421U6foRK16XYV+7VD2udTrUZ+A/2vvOwTE9wPo20LpJ5fu8PMTUyFsfu9FKAVTo9QYa0BWUWUof7N4B/8sZgX6haVWWEvlAZcbEUOBeiRtjv0QIhVXYrEqGxbwJJpofF2WsRGA+lLCyYatK+tYKlmDo5X32MaPG4gWjRYkK2PxdhJeHZWMcUKUB/7dUSpqzscjaAfmcP57aZyqaGhdp/atZU2DP/SN8FwjtJBt4E/r1st8FCFRMN0R8/1KMtjZEmRMdTC82f+c0cpA8x1QhWSqanci9U/tCx7xT931KqkJpEP4m1mHyuALOaaob+kwcML6oasaod+a9acbrDbQb+hx2H7awukaaOFJdFW1qcsTEq8mmHjYNpATHETdALFVt/qtNni+OqETkxQw1oOImm9msfrFTNNJuvM3rDO0659Ul4hy7SG8kNJksMoi0n6t5wQhUTwP6UOoBZ8A1cptRs/CbJ4QenkkQp6DyLCs/wyKD1wVklYmDunRNVfePTZzv9jRyJvlCmIlAKbzrodvU9FcjBGXm0Z31qGexFlmK0hUofdQUEyGNzD773839QeacFNGfpSyaz5PmG2YnyvuVgQpIRauwhqJXReZY9RvfI3Ru2yuVFSN4O3H4MNi3C8/Jupryjl3euDjXHXrX+mU7S1DlscKfAaZdEgFJ71Ww7rcjZrj/8pNm+h2TOBjXeuoo64IeIDIvBXc3QrUlOArPMYKbYelCzrWZ/tvS/e73DWZIJzy21duj0Gxoot4Om/pjSsjZNU70xedogKdshmH3ptp70wAPl0sz2TQ1sPgs1V/aOSFRmnYrmyvZCfbWLtqrLC0ZWzduczPxRTmZual9YOu8jmQqfb3GbcTKHoouXUomL49t/5BRjxskMyKOrH4UMl+i0LovVD6MV0y91vBOjYjdU3e2STElZ+wJCtv7T3VFDZI020LCFnRarJtKHmhctNG+8zNQ635pQstayrdIN+5CbAUfSHddZnoOlz6yunGrTHjfqN6YEDF1VlgXZJPD0MehYIwXF1dVlCyC6iRSdmw2xp7VDsMLpNLVBZ33n22Ve7ItlHm6rrJ5DuPU0hCLsbwv+QVNjS/PQNntYuUjaVMoxoqMqxXjxpuZwl02VE+Rtl8vcYEjarvZtEc1BqzZT1uAQd+wE2QdXGwu+2TrYP+5WG2I1Aj/mLxsv35+DumDCtyvFJ9gDliN5+hrlDHUZUnNT5MDU3SxhS+d2SPOe1MUTXLKa4o/qI1d8KPDbNR5Q7FVz0Zrr2dpMfnK/rHetTDtaUmwo7TRMu9b7Y6/sT71qPNlN3G12EsbiCl7UoRLYp1UJBTf1qHjft4kFwxn+P8TOR7TttZOE1DfDwVKR8ru2bYxPmFrPUJLadZh84sWIVZm+WTpMs0hQDw+Z7K3WhP3lCiNMRojfuWuvT0u0daW6RX0EVz2dAZWMGXV91SaURMrZWj4CgHLNVsiWJ95/igz54MAmKwbmSIAZw4uBjWCJ0aukvXBRKNP3LOYuBASXl1y0bKJR2TX1V9VEsws6llmB/NB+RRNiKtWXq0gPjOVk65v/fm/6lNInqG/4cjZfMLL2fAeoTZas9HhWHvEX9/8ooUEPB70qY3Pv7aQTJWjLjPSA23WgyrbzWsGzOnZ1a5Xr9uq47p9ej8+vx1b8/rm297Pe7F9eH/7371YG4SL4Yw+yr7/9BwGYqXgZSwAA\",\"eos\":true}}\n,{\"compressed_inference_model\":{\"doc_num\":0,\"definition\":\"H4sIAAAAAAAA/81c224cOQ5938/oZ6cgUiQl+lcWg4bHrjgGfEO7vRcE+felnNnZtMhAtZppexzASAyrmipRh+ccUfm6ez6sz4en6/Xl5enwsrv8+y8Xu+Ph6u5xvdk/PN2s97vLr7v18WV9+PV+bX//vF4dXw/r/vHqYW2/v7uG3cXuGtu33L7Rrj3i6nC7HvfHfz/boN1hvT3YB9w9Pe66p7cnfLUfreGzRw9a1/3L8fB63Qa9PejRnrm/e7xZ/7W7TBe7x9eHX9fD/uXq4fm+PbDYz+7Xq8/7f1zdv9qItFAlJoVvv3z7dvHzOH6bYx7ObCagl+f7u+P+t498+63vP7m117S7ROWFsJI9/Yt90pen+5vd5SdYilJOerG7WT9fvd4f9/fr5+Pu0j57bT+7vmsh/TfI++OuzfvzcX/95a6Nh4vd4e72y+//xjb5H0MFH2qGYai0JM3lNFJZgBLAZKDcBSp9oBgEqi5QOA1U0wLIgqeR5gUAlXAy1NyFSn2o2Yfa3suP+fgJF0zIya0H+bFYh+uBliWlwMk06yJSVfLkLLWbJaQ+VA6m6bO8WxHCRbXKSaS0QM6gdTLS0kVa+0AleKfdesACJYuUfmjxQ3k0RcgLSUbqtwdLBZydJPQ7GVzq1DDWH2eJi9Qk3A/U4P3k0SzFUg4hnW6tvDCJ4CwIQL+1wO0tCLB1uCK8cLXl1dMVwQUS5zILA9BDFjjMggBdsQOCtKSUE5Gon2uEeW44VQFN6gZHKERudNUsXFzeQ4BD6gYjJU3BGkXI4AYDCXJxyQjBbqW+mDMUss8eFvP8O2GBD6joBihW0UX6ig4G1TQNBBMVHWW0Q6qlYS50ukOsqkiuOLtBZko60RBdU7a8K7WrIJos+tlaN1PRA5aEXaSwKPJpoJ/KUishyfnKQLBzwaM5OkanhtunlM4y1aCJy7nqcgQTw0zFBnipp3Rqr7oqzyYA9LHCFhIxZjtGBTRRC+uHYHnRYtBHZyNmAWkpjgikZGR9A4UQh73VeGvKG0iE38s9b13Inialp+fCCWR6i/QvCN0LikiEm2culvz+FUU1PfdjISUR8lU1QLyA3fc40rA5YC+1quK0MNxAtSIG4aaqpbJ6HRMRCBgSNVqq2LS4x0wyDaezOLSFqAVQ5BcVyJSLX9QIGTzLs7FEHq0h2KyeKxVi2yaeKwX7FdgpTcipotuwENF+55okfnNN+sodbCA/5Zwz5SpDlkbfCdoH+S4geakZTuWacVtQi35aycz4LkPNVRZlVjhFAlkUpMh7srRm/QwdCZSaueOTKfM0nZwhad4gQgc4XJmoZ5OqaXrtxwV6m8nTcwmD2lIrdqHaC9V5MTGmkwEy4vC1muAGrJ2XacsvpGm2rs/YPJ6BdIEawgFRzaeR6pKKMPP5Ck6E+sNNBUu2xOw2lenJTJYZ03RpTASiKuPRHo2MiCcCQZUZcvxGoMCqlieGQpZW70sMPSqnPlosqULGroJIYy3zW3MsSUJ7yRmbJbOR0S1UtPg1pZJrQJc2MEPLS3snlppbmKH3pSRpM4gmiNobXbL37n3OkKm5wQyUEP3gTUSNmO2jNxE1z7WyVAze1xae1uixOIoX0TT/qrFA1vpX99Jw4QIdSzNlIAyapoF6gqV5lHYGBXJBkN7+hySFzif6g/0sW2yfDKIdzrLxtHnqO3U8tgFkkymgmgQ6iyoXlmkvZc5O4/FZ7lJqTt755UJ6NqIe2Wl+t3OuBm9ucACN2ddpT/NqLp1raGoqkcCsFTekeQEO90XPsFQkSd3EZHq9bIDIaKrACf0xDr8dKWXMHv/jU6vuc5udo5uqPPfzLZg2+k3VGTiatBk421U6foRK16XYV+7VD2udTrUZ+A/2vvOwTE9wPo20LpJ5fu8PMTUyFsfu9FKAVTo9QYa0BWUWUof7N4B/8sZgX6haVWWEvlAZcbEUOBeiRtjv0QIhVXYrEqGxbwJJpofF2WsRGA+lLCyYatK+tYKlmDo5X32MaPG4gWjRYkK2PxdhJeHZWMcUKUB/7dUSpqzscjaAfmcP57aZyqaGhdp/atZU2DP/SN8FwjtJBt4E/r1st8FCFRMN0R8/1KMtjZEmRMdTC82f+c0cpA8x1QhWSqanci9U/tCx7xT931KqkJpEP4m1mHyuALOaaob+kwcML6oasaod+a9acbrDbQb+hx2H7awukaaOFJdFW1qcsTEq8mmHjYNpATHETdALFVt/qtNni+OqETkxQw1oOImm9msfrFTNNJuvM3rDO0659Ul4hy7SG8kNJksMoi0n6t5wQhUTwP6UOoBZ8A1cptRs/CbJ4QenkkQp6DyLCs/wyKD1wVklYmDunRNVfePTZzv9jRyJvlCmIlAKbzrodvU9FcjBGXm0Z31qGexFlmK0hUofdQUEyGNzD773839QeacFNGfpSyaz5PmG2YnyvuVgQpIRauwhqJXReZY9RvfI3Ru2yuVFSN4O3H4MNi3C8/Jupryjl3euDjXHXrX+mU7S1DlscKfAaZdEgFJ71Ww7rcjZrj/8pNm+h2TOBjXeuoo64IeIDIvBXc3QrUlOArPMYKbYelCzrWZ/tvS/e73DWZIJzy21duj0Gxoot4Om/pjSsjZNU70xedogKdshmH3ptp70wAPl0sz2TQ1sPgs1V/aOSFRmnYrmyvZCfbWLtqrLC0ZWzduczPxRTmZual9YOu8jmQqfb3GbcTKHoouXUomL49t/5BRjxskMyKOrH4UMl+i0LovVD6MV0y91vBOjYjdU3e2STElZ+wJCtv7T3VFDZI020LCFnRarJtKHmhctNG+8zNQ635pQstayrdIN+5CbAUfSHddZnoOlz6yunGrTHjfqN6YEDF1VlgXZJPD0MehYIwXF1dVlCyC6iRSdmw2xp7VDsMLpNLVBZ33n22Ve7ItlHm6rrJ5DuPU0hCLsbwv+QVNjS/PQNntYuUjaVMoxoqMqxXjxpuZwl02VE+Rtl8vcYEjarvZtEc1BqzZT1uAQd+wE2QdXGwu+2TrYP+5WG2I1Aj/mLxsv35+DumDCtyvFJ9gDliN5+hrlDHUZUnNT5MDU3SxhS+d2SPOe1MUTXLKa4o/qI1d8KPDbNR5Q7FVz0Zrr2dpMfnK/rHetTDtaUmwo7TRMu9b7Y6/sT71qPNlN3G12EsbiCl7UoRLYp1UJBTf1qHjft4kFwxn+P8TOR7TttZOE1DfDwVKR8ru2bYxPmFrPUJLadZh84sWIVZm+WTpMs0hQDw+Z7K3WhP3lCiNMRojfuWuvT0u0daW6RX0EVz2dAZWMGXV91SaURMrZWj4CgHLNVsiWJ95/igz54MAmKwbmSIAZw4uBjWCJ0aukvXBRKNP3LOYuBASXl1y0bKJR2TX1V9VEsws6llmB/NB+RRNiKtWXq0gPjOVk65v/fm/6lNInqG/4cjZfMLL2fAeoTZas9HhWHvEX9/8ooUEPB70qY3Pv7aQTJWjLjPSA23WgyrbzWsGzOnZ1a5Xr9uq47p9ej8+vx1b8/rm297Pe7F9eH/7371YG4SL4Yw+yr7/9BwGYqXgZSwAA\",\"eos\":true}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-4.978199,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.1856499,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.1454616,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-4.460028,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":1.643608,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":11.66935,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":6.449406,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-1.651949,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-1.431112,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":5.957064,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":6.531394,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":1.916028,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-3.202722,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":4.401132,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":3.176036,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-3.262762,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":9.79813,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.4056594,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-2.103299,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":4.711451,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":6.600036,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-10.10891,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":5.268023,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":6.372826,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-2.329821,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-6.211882,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":3.840094,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":2.392636,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-4.116221,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.06490951,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-7.632752,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-6.97257,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.283581,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":1.867715,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-1.77209,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-11.01916,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.6186131,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":3.61408,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":4.495405,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-4.042377,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":2.327649,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":1.776945,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-1.152582,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":4.170098,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.701755,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":5.661319,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":0.8796449,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":5.454208,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-5.780083,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.8118424,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":8.506525,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.9182748,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":0.7343156,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-6.68997,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":11.22411,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":6.840355,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":8.387185,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-6.993784,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":5.391653,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-3.177985,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-7.313002,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-1.248203,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-4.542601,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":0.9235312,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-6.91104,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-0.902207,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-3.477778,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":-1.264715,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":6.052814,\"is_training\":true}}}}\n,{\"row_results\":{\"checksum\":0,\"results\":{\"ml\":{\"target_prediction\":3.770232,\"is_training\":true}}}}\n,{\"model_metadata\":{\"total_feature_importance\":[],\"hyperparameters\":[{\"name\":\"soft_tree_depth_tolerance\",\"value\":0.15,\"absolute_importance\":0.06414481,\"relative_importance\":0.6031168,\"supplied\":false},{\"name\":\"lambda\",\"value\":0.9963471,\"absolute_importance\":0.03006686,\"relative_importance\":0.2827014,\"supplied\":false},{\"name\":\"eta\",\"value\":0.3805847,\"absolute_importance\":0.01167569,\"relative_importance\":0.1097798,\"supplied\":false},{\"name\":\"gamma\",\"value\":0.03392016,\"absolute_importance\":0,\"relative_importance\":0,\"supplied\":false},{\"name\":\"soft_tree_depth_limit\",\"value\":9.228819,\"absolute_importance\":0,\"relative_importance\":0,\"supplied\":false},{\"name\":\"downsample_factor\",\"value\":0.3423561,\"absolute_importance\":0,\"relative_importance\":0,\"supplied\":false},{\"name\":\"alpha\",\"value\":8.878184,\"absolute_importance\":0,\"relative_importance\":0,\"supplied\":false},{\"name\":\"eta_growth_rate_per_tree\",\"value\":1.190292,\"absolute_importance\":0,\"relative_importance\":0,\"supplied\":false},{\"name\":\"max_trees\",\"value\":10,\"supplied\":true},{\"name\":\"feature_bag_fraction\",\"value\":0.4,\"absolute_importance\":0,\"relative_importance\":0,\"supplied\":false}],\"train_properties\":{\"num_train_rows\":70,\"loss_gap\":3.44645,\"trained_model_memory_usage\":0},\"data_summarization\":{\"num_rows\":7}}}\n,{\"compressed_data_summarization\":{\"doc_num\":0,\"data_summarization\":\"H4sIAAAAAAAA/3VS7arbMAz9v8fw78ZYH7asvkopIaTZJdCmo00vG6XvPtm57TqWQWIi+eicIyl3N91ObX8+3k7T1W3jxi3f7dSdBkvsXA/OklgOKgfbMXeXj2F2+xd6vLZ9Nw8f58vYd0cr+94dr8PmP6fVDVN/PozTx7Udp8PYV6n7K1vV3XbRfiUNOfx02/DYrCBxBQmrSFpB4iqSV5C0hvyax79ofrz36rZ3Jz5awTv0c+jn86XcjYdhmsf5V/u8K8k3yh+3uX0OfOF3f1k8jb2lgns8HraZP/t4Fn12x1ud9G6/eXvM4qGbu5J32aeQNRJnI27IM+QsAMki9hQCiZAsAZHGJGXuTfBJBBmVov0UO7sNknJiLPYa8EIRQsBS2BQa4wyiFiUvSRkBFhzGGMV4K0nwmlQwAceKxExKDEUQfVTmAJmrFclmJGCxHD0qZ5WQK0ejxUkiZqgcLEGRinJj0hqyKUAlBCIoUAvIC4tiMveVI3sOAvaWP0fMPkZKmha1oGryud4gW9MaCj2gDxADcFo4yOfAIrGqZQ8SM2WWKq0siJpKY+Ctwyi5jj/5iDY0zUsv4hWIKXKqYlGRc/gyDGYfNeuyDFIw4VyNlNXY2gjFnOwf334DxRlEGfEDAAA=\",\"eos\":true}}\n]"; json::value results = json::parse(resultsJson, ec); @@ -457,7 +457,7 @@ void readPredictions(const std::string& resultsJson, const std::string& targetPredictionName, TDoubleVec& predictions) { - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(resultsJson, ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -597,7 +597,7 @@ BOOST_AUTO_TEST_CASE(testMemoryLimitHandling) { // Verify memory status change. Initially we should be ok, but hit the hard // limit during training. - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -653,7 +653,7 @@ BOOST_AUTO_TEST_CASE(testRegressionTraining) { analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); std::uint64_t duration{watch.stop()}; - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -762,7 +762,7 @@ BOOST_AUTO_TEST_CASE(testRegressionTrainingWithRowsMissingTargetValue) { } analyzer.handleRecord(fieldNames, {"", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -1128,7 +1128,7 @@ BOOST_AUTO_TEST_CASE(testRegressionIncrementalTraining) { fieldNames, fieldValues, analyzerIncremental, weights, regressors, targets); analyzerIncremental.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(outputStream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -1228,7 +1228,7 @@ BOOST_AUTO_TEST_CASE(testClassificationTraining) { analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); std::uint64_t duration{watch.stop()}; - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -1334,7 +1334,7 @@ BOOST_AUTO_TEST_CASE(testClassificationImbalancedClasses) { fieldNames, fieldValues, analyzer, weights, regressors, actuals); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -1419,7 +1419,7 @@ BOOST_AUTO_TEST_CASE(testClassificationWithUserClassWeights) { } }); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -1561,7 +1561,7 @@ BOOST_AUTO_TEST_CASE(testClassificationIncrementalTraining) { fieldNames, fieldValues, analyzerIncremental, weights, regressors, targets); analyzerIncremental.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(outputStream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -1849,7 +1849,7 @@ BOOST_AUTO_TEST_CASE(testIncrementalTrainingFieldMismatch) { fieldNames, fieldValues, analyzerIncremental, weights, regressors, targets); analyzerIncremental.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(outputStream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -2158,7 +2158,7 @@ BOOST_AUTO_TEST_CASE(testProgressMonitoring) { TLossFunctionType::E_MseRegression, fieldNames, fieldValues, analyzer, 300); analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -2254,7 +2254,7 @@ BOOST_AUTO_TEST_CASE(testProgressMonitoringFromRestart) { TLossFunctionType::E_MseRegression, fieldNames, fieldValues, restoredAnalyzer, 400); restoredAnalyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); diff --git a/lib/api/unittest/CDataFrameTrainBoostedTreeClassifierRunnerTest.cc b/lib/api/unittest/CDataFrameTrainBoostedTreeClassifierRunnerTest.cc index ec0f12564d..fd5b18c9d2 100644 --- a/lib/api/unittest/CDataFrameTrainBoostedTreeClassifierRunnerTest.cc +++ b/lib/api/unittest/CDataFrameTrainBoostedTreeClassifierRunnerTest.cc @@ -91,7 +91,7 @@ void testWriteOneRow(const std::string& dependentVariableField, .predictionSpec(test::CDataFrameAnalysisSpecificationFactory::classification(), dependentVariableField); - json::error_code ec; + boost::system::error_code ec; json::value jsonParameters = json::parse( specFactory.predictionParams( test::CDataFrameAnalysisSpecificationFactory::classification(), dependentVariableField), diff --git a/lib/api/unittest/CDataFrameTrainBoostedTreeRegressionRunnerTest.cc b/lib/api/unittest/CDataFrameTrainBoostedTreeRegressionRunnerTest.cc index 6d62e94f57..ff2fbd3c09 100644 --- a/lib/api/unittest/CDataFrameTrainBoostedTreeRegressionRunnerTest.cc +++ b/lib/api/unittest/CDataFrameTrainBoostedTreeRegressionRunnerTest.cc @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(testPredictionFieldNameClash) { auto spec = specFactory.rows(5).columns(6).memoryLimit(13000000).predictionSpec( test::CDataFrameAnalysisSpecificationFactory::regression(), "dep_var"); - json::error_code ec; + boost::system::error_code ec; json::value jsonParameters = json::parse("{" " \"dependent_variable\": \"dep_var\"," " \"prediction_field_name\": \"is_training\"" diff --git a/lib/api/unittest/CDataSummarizationJsonSerializerTest.cc b/lib/api/unittest/CDataSummarizationJsonSerializerTest.cc index 7d23d692c7..e50f5ec187 100644 --- a/lib/api/unittest/CDataSummarizationJsonSerializerTest.cc +++ b/lib/api/unittest/CDataSummarizationJsonSerializerTest.cc @@ -119,7 +119,7 @@ void testSchema(TLossFunctionType lossType) { BOOST_REQUIRE_MESSAGE(schemaFileStream.is_open(), "Cannot open test file!"); std::string schemaJson((std::istreambuf_iterator(schemaFileStream)), std::istreambuf_iterator()); - json::error_code ec; + boost::system::error_code ec; json::value schemaDocument = json::parse(schemaJson, ec); BOOST_REQUIRE_MESSAGE(ec.failed() == false, "Cannot parse JSON schema!"); diff --git a/lib/api/unittest/CForecastRunnerTest.cc b/lib/api/unittest/CForecastRunnerTest.cc index 39caad79dd..edad0e0b44 100644 --- a/lib/api/unittest/CForecastRunnerTest.cc +++ b/lib/api/unittest/CForecastRunnerTest.cc @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(testSummaryCount) { BOOST_TEST_REQUIRE(job.handleRecord(dataRows)); } - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(outputStrm.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc.as_array().size() > 0); @@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(testPopulation) { BOOST_TEST_REQUIRE(job.handleRecord(dataRows)); } - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(outputStrm.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc.is_array()); @@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(testRare) { ",\"expires_in\": \"8640000\" }"; BOOST_TEST_REQUIRE(job.handleRecord(dataRows)); } - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(outputStrm.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc.is_array()); @@ -257,7 +257,7 @@ BOOST_AUTO_TEST_CASE(testInsufficientData) { BOOST_TEST_REQUIRE(job.handleRecord(dataRows)); } - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(outputStrm.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc.is_array()); diff --git a/lib/api/unittest/CInferenceModelMetadataTest.cc b/lib/api/unittest/CInferenceModelMetadataTest.cc index d7bbddcf89..bc58c6e775 100644 --- a/lib/api/unittest/CInferenceModelMetadataTest.cc +++ b/lib/api/unittest/CInferenceModelMetadataTest.cc @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(testJsonSchema) { analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(testHyperparameterReproducibility, *utf::tolerance(0.000001 analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(testHyperparameterReproducibility, *utf::tolerance(0.000001 analyzer.handleRecord(fieldNames, {"", "", "", "", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); @@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(testDataSummarization) { analyzer.handleRecord(fieldNames, {"", "", "", "$"}); - json::error_code ec; + boost::system::error_code ec; json::value results = json::parse(output.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(results.is_array()); diff --git a/lib/api/unittest/CJsonOutputWriterTest.cc b/lib/api/unittest/CJsonOutputWriterTest.cc index 16772158f8..a1097c4859 100644 --- a/lib/api/unittest/CJsonOutputWriterTest.cc +++ b/lib/api/unittest/CJsonOutputWriterTest.cc @@ -213,7 +213,7 @@ void testBucketWriteHelper(bool isInterim) { BOOST_TEST_REQUIRE(writer.endOutputBatch(isInterim, 10U)); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(arrayDoc.is_array()); @@ -708,7 +708,7 @@ void testLimitedRecordsWriteHelper(bool isInterim) { BOOST_TEST_REQUIRE(writer.endOutputBatch(isInterim, 10U)); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); LOG_DEBUG(<< "Results:\n" << arrayDoc_); @@ -1033,7 +1033,7 @@ BOOST_AUTO_TEST_CASE(testGeoResultsWrite) { BOOST_TEST_REQUIRE(writer.acceptResult(result)); BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); // Debug print record { LOG_DEBUG(<< "Results:\n" << arrayDoc_); } @@ -1072,7 +1072,7 @@ BOOST_AUTO_TEST_CASE(testGeoResultsWrite) { BOOST_TEST_REQUIRE(writer.acceptResult(result)); BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record @@ -1107,7 +1107,7 @@ BOOST_AUTO_TEST_CASE(testGeoResultsWrite) { BOOST_TEST_REQUIRE(writer.acceptResult(result)); BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record @@ -1147,7 +1147,7 @@ BOOST_AUTO_TEST_CASE(testWriteNonAnomalousBucket) { writer.finalise(); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record @@ -1185,7 +1185,7 @@ BOOST_AUTO_TEST_CASE(testFlush) { writer.acknowledgeFlush(testId, lastFinalizedBucketEnd); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(arrayDoc_.is_array()); @@ -1228,7 +1228,7 @@ BOOST_AUTO_TEST_CASE(testWriteCategoryDefinition) { maxMatchingLength, examples, 0, {}); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(arrayDoc_.is_array()); @@ -1287,7 +1287,7 @@ BOOST_AUTO_TEST_CASE(testWritePerPartitionCategoryDefinition) { regex, maxMatchingLength, examples, 0, {}); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(arrayDoc_.is_array()); @@ -1368,7 +1368,7 @@ BOOST_AUTO_TEST_CASE(testWriteInfluencers) { BOOST_TEST_REQUIRE(writer.endOutputBatch(true, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc_.is_array()); @@ -1482,7 +1482,7 @@ BOOST_AUTO_TEST_CASE(testWriteInfluencersWithLimit) { BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc_.is_array()); @@ -1620,7 +1620,7 @@ BOOST_AUTO_TEST_CASE(testWriteWithInfluences) { BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record @@ -1695,7 +1695,7 @@ BOOST_AUTO_TEST_CASE(testPersistNormalizer) { writer.finalise(); } - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record @@ -1752,7 +1752,7 @@ BOOST_AUTO_TEST_CASE(testReportMemoryUsage) { LOG_DEBUG(<< sstream.str()); - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc_.is_array()); @@ -1833,7 +1833,7 @@ BOOST_AUTO_TEST_CASE(testWriteCategorizerStats) { LOG_DEBUG(<< sstream.str()); - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc_.is_array()); @@ -1919,7 +1919,7 @@ BOOST_AUTO_TEST_CASE(testWriteScheduledEvent) { BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 1U)); } - json::error_code ec; + boost::system::error_code ec; json::value doc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record @@ -1991,7 +1991,7 @@ BOOST_AUTO_TEST_CASE(testRareAnomalyScoreExplanation) { BOOST_TEST_REQUIRE(writer.endOutputBatch(false, 10U)); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc_ = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); // Debug print record diff --git a/lib/api/unittest/CMemoryUsageEstimationResultJsonWriterTest.cc b/lib/api/unittest/CMemoryUsageEstimationResultJsonWriterTest.cc index 104b83b425..eda64e0ce2 100644 --- a/lib/api/unittest/CMemoryUsageEstimationResultJsonWriterTest.cc +++ b/lib/api/unittest/CMemoryUsageEstimationResultJsonWriterTest.cc @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(testWrite) { writer.write("16mb", "8mb"); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(arrayDoc.is_array()); diff --git a/lib/api/unittest/CModelPlotDataJsonWriterTest.cc b/lib/api/unittest/CModelPlotDataJsonWriterTest.cc index 7f37717481..69877d44ae 100644 --- a/lib/api/unittest/CModelPlotDataJsonWriterTest.cc +++ b/lib/api/unittest/CModelPlotDataJsonWriterTest.cc @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(testWriteFlat) { writer.writeFlat("job-id", plotData); } - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc.is_array()); diff --git a/lib/api/unittest/CModelSnapshotJsonWriterTest.cc b/lib/api/unittest/CModelSnapshotJsonWriterTest.cc index ff404b7f91..79a3f59217 100644 --- a/lib/api/unittest/CModelSnapshotJsonWriterTest.cc +++ b/lib/api/unittest/CModelSnapshotJsonWriterTest.cc @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(testWrite) { writer.write(report); } - json::error_code ec; + boost::system::error_code ec; json::value arrayDoc = json::parse(sstream.str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(arrayDoc.is_array()); diff --git a/lib/api/unittest/CMultiFileDataAdderTest.cc b/lib/api/unittest/CMultiFileDataAdderTest.cc index a88636e980..c57b623923 100644 --- a/lib/api/unittest/CMultiFileDataAdderTest.cc +++ b/lib/api/unittest/CMultiFileDataAdderTest.cc @@ -134,7 +134,7 @@ void detectorPersistHelper(const std::string& configFileName, origFileContents[index] = json; // Ensure that the JSON is valid, by parsing string using boost::json - json::error_code ec; + boost::system::error_code ec; json::value document = json::parse(origFileContents[index].c_str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(document.is_object()); diff --git a/lib/api/unittest/CResultNormalizerTest.cc b/lib/api/unittest/CResultNormalizerTest.cc index 23fa92264c..b68d049426 100644 --- a/lib/api/unittest/CResultNormalizerTest.cc +++ b/lib/api/unittest/CResultNormalizerTest.cc @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(testInitNormalizerPartitioned) { std::vector resultDocs; std::stringstream ss(results); std::string docString; - json::error_code ec; + boost::system::error_code ec; while (std::getline(ss, docString)) { json::value doc = json::parse(docString.c_str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); @@ -409,7 +409,7 @@ BOOST_AUTO_TEST_CASE(testInitNormalizer) { std::vector resultDocs; std::stringstream ss(results); std::string docString; - json::error_code ec; + boost::system::error_code ec; while (std::getline(ss, docString)) { json::value doc = json::parse(docString, ec); BOOST_TEST_REQUIRE(ec.failed() == false); diff --git a/lib/api/unittest/CSerializableToJsonTest.cc b/lib/api/unittest/CSerializableToJsonTest.cc index 5074079628..b4bae95383 100644 --- a/lib/api/unittest/CSerializableToJsonTest.cc +++ b/lib/api/unittest/CSerializableToJsonTest.cc @@ -80,7 +80,7 @@ class CSerializableVector : public api::CSerializableToCompressedChunkedJson, void readFromJsonStream(TIStreamPtr inputStream) { if (inputStream != nullptr) { - json::error_code ec; + boost::system::error_code ec; json::parse_options opts; opts.numbers = json::number_precision::precise; json::value doc = json::parse(*inputStream, ec, {}, opts); @@ -103,7 +103,7 @@ class CSerializableVector : public api::CSerializableToCompressedChunkedJson, void arrayToNdJson(std::string array, std::ostream& ndjson) { array.erase(std::remove(array.begin(), array.end(), '\n'), array.end()); - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(array, ec); BOOST_TEST_REQUIRE(ec.failed() == false); BOOST_TEST_REQUIRE(doc.is_array()); diff --git a/lib/core/CJsonStateRestoreTraverser.cc b/lib/core/CJsonStateRestoreTraverser.cc index 2b62c4478f..5737d4c2b8 100644 --- a/lib/core/CJsonStateRestoreTraverser.cc +++ b/lib/core/CJsonStateRestoreTraverser.cc @@ -252,7 +252,7 @@ bool CJsonStateRestoreTraverser::parseNext(bool remember) { } } - json::error_code ec; + boost::system::error_code ec; char c = *m_BufferPtr; std::size_t written = m_Reader.write_some(true, &c, 1, ec); if (ec) { @@ -423,7 +423,7 @@ CJsonStateRestoreTraverser::SBoostJsonHandler::SBoostJsonHandler() s_IsEndOfLevel[1] = false; } -bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_null(json::error_code& ec) { +bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_null(boost::system::error_code& ec) { s_Type = E_TokenNull; if (ec) { LOG_ERROR(<< "on_null: ERROR: " << ec.to_string()); @@ -433,7 +433,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_null(json::error_code& ec return true; } -bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_bool(bool b, json::error_code& ec) { +bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_bool(bool b, boost::system::error_code& ec) { s_Type = E_TokenBool; if (ec) { LOG_ERROR(<< "on_bool: ERROR: b: " << b << ". " << ec.to_string()); @@ -449,7 +449,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_bool(bool b, json::error_ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_int64(std::int64_t i, std::string_view s, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenInt64; if (ec) { LOG_ERROR(<< "on_int64: ERROR: i: " << i << ", s: '" << s << "'. " @@ -469,7 +469,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_int64(std::int64_t i, bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_uint64(std::uint64_t u, std::string_view s, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenUInt64; if (ec) { LOG_ERROR(<< "on_uint64: ERROR: u: " << u << ", s: '" << s << "'. " @@ -489,7 +489,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_uint64(std::uint64_t u, bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_double(double d, std::string_view s, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenDouble; if (ec) { LOG_ERROR(<< "on_double: ERROR: d: " << d << ", s: '" << s << "'. " @@ -509,7 +509,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_double(double d, bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_string_part(std::string_view s, std::size_t n, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenStringPart; if (ec) { LOG_ERROR(<< "on_string_part: ERROR: s: '" << s << "', n: " << n << ". " @@ -530,7 +530,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_string_part(std::string_v bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_string(std::string_view s, std::size_t n, - json::error_code& ec) { + boost::system::error_code& ec) { if (ec) { LOG_ERROR(<< "on_string: ERROR: s: '" << s << "', n: " << n << ". " << ec.to_string()); @@ -552,13 +552,13 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_string(std::string_view s return true; } -bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_document_begin(json::error_code& ec) { +bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_document_begin(boost::system::error_code& ec) { LOG_TRACE(<< "on_document_begin"); return (ec) ? false : true; } -bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_object_begin(json::error_code& ec) { +bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_object_begin(boost::system::error_code& ec) { LOG_TRACE(<< "on_object_begin"); if (ec) { return false; @@ -576,7 +576,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_object_begin(json::error_ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_key_part(std::string_view s, std::size_t n, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenKeyPart; if (ec) { LOG_ERROR(<< "on_key_part: ERROR: s: '" << s << "', n: " << n << ". " @@ -597,7 +597,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_key_part(std::string_view bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_key(std::string_view s, std::size_t n, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenKey; if (ec) { LOG_ERROR(<< "on_key: ERROR: s: '" << s << "', n: " << n << ". " << ec.to_string()); @@ -617,7 +617,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_key(std::string_view s, } bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_object_end(std::size_t n, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenObjectEnd; if (ec) { LOG_ERROR(<< "on_object_end: ERROR: n: " << n << ". " << ec.to_string()); @@ -637,7 +637,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_object_end(std::size_t n, return true; } -bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_array_begin(json::error_code& ec) { +bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_array_begin(boost::system::error_code& ec) { s_Type = E_TokenArrayStart; if (ec) { LOG_ERROR(<< "on_array_begin: ERROR: " << ec.to_string()); @@ -650,7 +650,7 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_array_begin(json::error_c } bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_array_end(std::size_t n, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenArrayEnd; if (ec) { LOG_ERROR(<< "on_array_end: ERROR: n: " << n << ". " << ec.to_string()); @@ -662,17 +662,17 @@ bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_array_end(std::size_t n, } bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_number_part(std::string_view /* s*/, - json::error_code& ec) { + boost::system::error_code& ec) { return (ec) ? false : true; } bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_comment_part(std::string_view /* s*/, - json::error_code& ec) { + boost::system::error_code& ec) { return (ec) ? false : true; } bool CJsonStateRestoreTraverser::SBoostJsonHandler::on_comment(std::string_view /* s*/, - json::error_code& ec) { + boost::system::error_code& ec) { return (ec) ? false : true; } } diff --git a/lib/core/CStateDecompressor.cc b/lib/core/CStateDecompressor.cc index acea58898e..5e96961853 100644 --- a/lib/core/CStateDecompressor.cc +++ b/lib/core/CStateDecompressor.cc @@ -135,7 +135,7 @@ bool CStateDecompressor::CDechunkFilter::parseNext() { // to immediately return. That is, we don't want to trigger multiple parser // callbacks for every call to parseNext as that will clobber the state // we've been building up. - json::error_code ec; + boost::system::error_code ec; m_Reader->write_some(true, &c, 1, ec); if (ec) { LOG_ERROR(<< "Error parsing JSON: " << ec.message()); @@ -273,7 +273,7 @@ std::streamsize CStateDecompressor::CDechunkFilter::endOfStream(char* s, void CStateDecompressor::CDechunkFilter::close() { } -bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_bool(bool, json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_bool(bool, boost::system::error_code& ec) { s_Type = E_TokenBool; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -286,7 +286,7 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_bool(bool, json:: bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_string(std::string_view str, std::size_t length, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenString; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -308,9 +308,10 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_string(std::strin return true; } -bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_string_part(std::string_view str, - std::size_t length, - json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_string_part( + std::string_view str, + std::size_t length, + boost::system::error_code& ec) { s_Type = E_TokenStringPart; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -331,7 +332,7 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_string_part(std:: bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_key(std::string_view str, std::size_t length, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenKey; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -352,9 +353,10 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_key(std::string_v return true; } -bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_key_part(std::string_view str, - std::size_t length, - json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_key_part( + std::string_view str, + std::size_t length, + boost::system::error_code& ec) { s_Type = E_TokenKeyPart; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -372,7 +374,7 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_key_part(std::str return true; } -bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_object_begin(json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_object_begin(boost::system::error_code& ec) { s_Type = E_TokenObjectStart; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -385,7 +387,7 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_object_begin(json } bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_object_end(std::size_t, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenObjectEnd; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -397,7 +399,7 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_object_end(std::s return true; } -bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_array_begin(json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_array_begin(boost::system::error_code& ec) { s_Type = E_TokenArrayStart; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -410,7 +412,7 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_array_begin(json: } bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_array_end(std::size_t, - json::error_code& ec) { + boost::system::error_code& ec) { s_Type = E_TokenArrayEnd; if (ec) { LOG_ERROR(<< "Parse error: " << ec.message()); @@ -422,50 +424,56 @@ bool CStateDecompressor::CDechunkFilter::SBoostJsonHandler::on_array_end(std::si return true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_document_begin(json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_document_begin( + boost::system::error_code& ec) { return (ec) ? false : true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_document_end(json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_document_end( + boost::system::error_code& ec) { return (ec) ? false : true; } bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_number_part( std::string_view /* s */, - json::error_code& ec) { + boost::system::error_code& ec) { return (ec) ? false : true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_int64(int64_t /* i */, - std::string_view /* s */, - json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_int64( + int64_t /* i */, + std::string_view /* s */, + boost::system::error_code& ec) { return (ec) ? false : true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_uint64(uint64_t /* u */, - std::string_view /* s */, - json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_uint64( + uint64_t /* u */, + std::string_view /* s */, + boost::system::error_code& ec) { return (ec) ? false : true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_double(double /* d */, - std::string_view /* s */, - json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_double( + double /* d */, + std::string_view /* s */, + boost::system::error_code& ec) { return (ec) ? false : true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_null(json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_null(boost::system::error_code& ec) { return (ec) ? false : true; } bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_comment_part( std::string_view /* s */, - json::error_code& ec) { + boost::system::error_code& ec) { return (ec) ? false : true; } -bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_comment(std::string_view /* s */, - json::error_code& ec) { +bool CStateDecompressor::CDechunkFilter::SBaseBoostJsonHandler::on_comment( + std::string_view /* s */, + boost::system::error_code& ec) { return (ec) ? false : true; } diff --git a/lib/core/unittest/CJsonOutputStreamWrapperTest.cc b/lib/core/unittest/CJsonOutputStreamWrapperTest.cc index 53df3b02b0..1c80628f95 100644 --- a/lib/core/unittest/CJsonOutputStreamWrapperTest.cc +++ b/lib/core/unittest/CJsonOutputStreamWrapperTest.cc @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(testConcurrentWrites) { } } - json::error_code ec; + boost::system::error_code ec; json::value doc = json::parse(stringStream.str(), ec); // check that the document isn't malformed (like wrongly interleaved buffers) diff --git a/lib/core/unittest/CLoggerTest.cc b/lib/core/unittest/CLoggerTest.cc index e626fb8fcd..994ce3f89b 100644 --- a/lib/core/unittest/CLoggerTest.cc +++ b/lib/core/unittest/CLoggerTest.cc @@ -79,7 +79,7 @@ void loggedExpectedMessages(const std::string& logging, const TStrVec& messages) continue; } json::value doc; - json::error_code ec; + boost::system::error_code ec; p.write(line, ec); doc = p.release(); LOG_INFO(<< "doc: " << doc); diff --git a/lib/model/unittest/CAnomalyScoreTest.cc b/lib/model/unittest/CAnomalyScoreTest.cc index 8fc8764276..a169ae80f6 100644 --- a/lib/model/unittest/CAnomalyScoreTest.cc +++ b/lib/model/unittest/CAnomalyScoreTest.cc @@ -805,7 +805,7 @@ BOOST_AUTO_TEST_CASE(testJsonConversion) { std::string toJson = ss.str(); boost::json::value val; - boost::json::error_code ec; + boost::system::error_code ec; boost::json::parser p; p.write(toJson.c_str(), ec); BOOST_TEST_REQUIRE(ec.failed() == false); From 57e3c4c654b605c1822a907089a829bb78ad32a1 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Thu, 30 Jul 2026 16:07:07 +1200 Subject: [PATCH 20/20] [ML] Compute cut size once in CBootstrapClusterer trace log The best-cut LOG_TRACE recomputed std::count over the parities vector twice (once for |A|, once for |B|), doubling the O(V) work on a hot path when trace logging is compiled in. Compute |A| once and derive |B| from it, inside an EXCLUDE_TRACE_LOGGING guard so the local doesn't become an unused variable when trace logging is compiled out. Addresses a Copilot review note on #2985. Co-authored-by: Cursor --- include/maths/common/CBootstrapClusterer.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/maths/common/CBootstrapClusterer.h b/include/maths/common/CBootstrapClusterer.h index 727dbf13c4..19e9c14f10 100644 --- a/include/maths/common/CBootstrapClusterer.h +++ b/include/maths/common/CBootstrapClusterer.h @@ -730,13 +730,18 @@ class CBootstrapClusterer { cost = lowestCost; parities.swap(best); - LOG_TRACE(<< "Best cut |A| = " - << static_cast( - std::count(parities.begin(), parities.end(), true)) - << ", |B| = " - << V - static_cast( - std::count(parities.begin(), parities.end(), true)) - << ", cost = " << cost << ", threshold = " << threshold); +#ifndef EXCLUDE_TRACE_LOGGING + { + // Count |A| once and derive |B| from it: computing std::count twice + // inline would double the O(V) work on this hot path in trace-enabled + // builds. The block is guarded so the local isn't an unused variable + // when trace logging is compiled out (EXCLUDE_TRACE_LOGGING). + std::size_t sizeA{static_cast( + std::count(parities.begin(), parities.end(), true))}; + LOG_TRACE(<< "Best cut |A| = " << sizeA << ", |B| = " << V - sizeA + << ", cost = " << cost << ", threshold = " << threshold); + } +#endif return cost < threshold; }