From b616085ef323936aa99379fd1bff0e08cd404374 Mon Sep 17 00:00:00 2001 From: Tom Veasey Date: Thu, 13 Dec 2018 10:54:49 +0000 Subject: [PATCH] [6.5][ML] Write out forecasts predictions at "bucket time" rather than the actual times they are made in the time buckets (#341) Backports #332. --- lib/model/CForecastDataSink.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/model/CForecastDataSink.cc b/lib/model/CForecastDataSink.cc index 8e5818755d..21a67ec8d3 100644 --- a/lib/model/CForecastDataSink.cc +++ b/lib/model/CForecastDataSink.cc @@ -9,6 +9,8 @@ #include #include +#include + #include #include @@ -221,9 +223,11 @@ void CForecastDataSink::push(const maths::SErrorBar errorBar, m_Writer.addIntFieldToObj(DETECTOR_INDEX, detectorIndex, doc); m_Writer.addStringFieldReferenceToObj(FORECAST_ID, m_ForecastId, doc); m_Writer.addStringFieldCopyToObj(FEATURE, feature, doc, true); - - // time is in Java format - milliseconds since the epoch - m_Writer.addTimeFieldToObj(TIMESTAMP, errorBar.s_Time, doc); + // Time is in Java format - milliseconds since the epoch. Note this + // matches the Java notion of "bucket time" which is defined as the + // start of the bucket containing the forecast time. + core_t::TTime time{maths::CIntegerTools::floor(errorBar.s_Time, errorBar.s_BucketLength)}; + m_Writer.addTimeFieldToObj(TIMESTAMP, time, doc); m_Writer.addIntFieldToObj(BUCKET_SPAN, errorBar.s_BucketLength, doc); if (!partitionFieldName.empty()) { m_Writer.addStringFieldCopyToObj(PARTITION_FIELD_NAME, partitionFieldName, doc);