Skip to content

Commit

Permalink
[ML] Write out forecasts predictions at "bucket time" rather than the…
Browse files Browse the repository at this point in the history
… actual times they are made in the time buckets (elastic#333)
  • Loading branch information
tveasey committed Dec 13, 2018
1 parent 8b723aa commit 7651e51
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/model/CForecastDataSink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <core/CLogger.h>
#include <core/CScopedRapidJsonPoolAllocator.h>

#include <maths/CIntegerTools.h>

#include <boost/bind.hpp>

#include <vector>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7651e51

Please sign in to comment.