|
9 | 9 | #include <core/CLogger.h> |
10 | 10 | #include <core/CScopedRapidJsonPoolAllocator.h> |
11 | 11 |
|
| 12 | +#include <maths/CIntegerTools.h> |
| 13 | + |
12 | 14 | #include <boost/bind.hpp> |
13 | 15 |
|
14 | 16 | #include <vector> |
@@ -221,9 +223,11 @@ void CForecastDataSink::push(const maths::SErrorBar errorBar, |
221 | 223 | m_Writer.addIntFieldToObj(DETECTOR_INDEX, detectorIndex, doc); |
222 | 224 | m_Writer.addStringFieldReferenceToObj(FORECAST_ID, m_ForecastId, doc); |
223 | 225 | m_Writer.addStringFieldCopyToObj(FEATURE, feature, doc, true); |
224 | | - |
225 | | - // time is in Java format - milliseconds since the epoch |
226 | | - m_Writer.addTimeFieldToObj(TIMESTAMP, errorBar.s_Time, doc); |
| 226 | + // Time is in Java format - milliseconds since the epoch. Note this |
| 227 | + // matches the Java notion of "bucket time" which is defined as the |
| 228 | + // start of the bucket containing the forecast time. |
| 229 | + core_t::TTime time{maths::CIntegerTools::floor(errorBar.s_Time, errorBar.s_BucketLength)}; |
| 230 | + m_Writer.addTimeFieldToObj(TIMESTAMP, time, doc); |
227 | 231 | m_Writer.addIntFieldToObj(BUCKET_SPAN, errorBar.s_BucketLength, doc); |
228 | 232 | if (!partitionFieldName.empty()) { |
229 | 233 | m_Writer.addStringFieldCopyToObj(PARTITION_FIELD_NAME, partitionFieldName, doc); |
|
0 commit comments