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