|
9 | 9 | #include <core/CLogger.h> |
10 | 10 | #include <core/CScopedRapidJsonPoolAllocator.h> |
11 | 11 |
|
| 12 | +#include <boost/bind.hpp> |
| 13 | + |
12 | 14 | #include <vector> |
13 | 15 |
|
14 | 16 | namespace ml { |
@@ -54,16 +56,34 @@ const std::string CForecastDataSink::STATUS("forecast_status"); |
54 | 56 |
|
55 | 57 | using TScopedAllocator = core::CScopedRapidJsonPoolAllocator<core::CRapidJsonConcurrentLineWriter>; |
56 | 58 |
|
57 | | -CForecastDataSink::SForecastModelWrapper::SForecastModelWrapper(model_t::EFeature feature, |
| 59 | +CForecastDataSink::CForecastModelWrapper::CForecastModelWrapper(model_t::EFeature feature, |
58 | 60 | TMathsModelPtr&& forecastModel, |
59 | 61 | const std::string& byFieldValue) |
60 | | - : s_Feature(feature), s_ForecastModel(std::move(forecastModel)), |
61 | | - s_ByFieldValue(byFieldValue) { |
| 62 | + : m_Feature(feature), m_ForecastModel(std::move(forecastModel)), |
| 63 | + m_ByFieldValue(byFieldValue) { |
| 64 | +} |
| 65 | + |
| 66 | +CForecastDataSink::CForecastModelWrapper::CForecastModelWrapper(CForecastModelWrapper&& other) |
| 67 | + : m_Feature(other.m_Feature), m_ForecastModel(std::move(other.m_ForecastModel)), |
| 68 | + m_ByFieldValue(std::move(other.m_ByFieldValue)) { |
62 | 69 | } |
63 | 70 |
|
64 | | -CForecastDataSink::SForecastModelWrapper::SForecastModelWrapper(SForecastModelWrapper&& other) |
65 | | - : s_Feature(other.s_Feature), s_ForecastModel(std::move(other.s_ForecastModel)), |
66 | | - s_ByFieldValue(std::move(other.s_ByFieldValue)) { |
| 71 | +bool CForecastDataSink::CForecastModelWrapper::forecast(const SForecastResultSeries& series, |
| 72 | + core_t::TTime startTime, |
| 73 | + core_t::TTime endTime, |
| 74 | + double boundsPercentile, |
| 75 | + CForecastDataSink& sink, |
| 76 | + std::string& message) const { |
| 77 | + core_t::TTime bucketLength{m_ForecastModel->params().bucketLength()}; |
| 78 | + startTime = model_t::sampleTime(m_Feature, startTime, bucketLength); |
| 79 | + endTime = model_t::sampleTime(m_Feature, endTime, bucketLength); |
| 80 | + model_t::TDouble1VecDouble1VecPr support{model_t::support(m_Feature)}; |
| 81 | + return m_ForecastModel->forecast( |
| 82 | + startTime, endTime, boundsPercentile, support.first, support.second, |
| 83 | + boost::bind(&model::CForecastDataSink::push, &sink, _1, model_t::print(m_Feature), |
| 84 | + series.s_PartitionFieldName, series.s_PartitionFieldValue, |
| 85 | + series.s_ByFieldName, m_ByFieldValue, series.s_DetectorIndex), |
| 86 | + message); |
67 | 87 | } |
68 | 88 |
|
69 | 89 | CForecastDataSink::SForecastResultSeries::SForecastResultSeries(const SModelParams& modelParams) |
|
0 commit comments