Skip to content

Commit fab3ad9

Browse files
committed
resource monitor is added to bucket gatherer init data
1 parent e82ff1a commit fab3ad9

8 files changed

+22
-11
lines changed

include/model/CBucketGatherer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class MODEL_EXPORT CBucketGatherer {
131131
using TMetricCategoryVec = std::vector<model_t::EMetricCategory>;
132132
using TTimeVec = std::vector<core_t::TTime>;
133133
using TTimeVecCItr = TTimeVec::const_iterator;
134+
using TOptionalResourceMonitorCRef = std::optional<std::reference_wrapper<const CResourceMonitor>>;
134135

135136
struct SBucketGathererInitData {
136137
static SBucketGathererInitData emptyData() {
@@ -143,6 +144,7 @@ class MODEL_EXPORT CBucketGatherer {
143144
const TStrVec& s_InfluenceFieldNames;
144145
core_t::TTime s_StartTime;
145146
unsigned int s_SampleOverrideCount;
147+
TOptionalResourceMonitorCRef s_ResourceMonitor;
146148
};
147149

148150
public:

include/model/CModelFactory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ class MODEL_EXPORT CModelFactory {
378378

379379
void resourceMonitor(const TResourceMonitorCRef& resourceMonitor) const;
380380

381+
TOptionalResourceMonitorCRef resourceMonitor() const;
382+
381383
protected:
382384
using TMultivariatePriorUPtrVec = std::vector<TMultivariatePriorUPtr>;
383385
using TOptionalSearchKey = std::optional<CSearchKey>;

lib/model/CCountingModelFactory.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ CCountingModelFactory::makeModel(const SModelInitializationData& initData,
6161

6262
CDataGatherer*
6363
CCountingModelFactory::makeDataGatherer(const SGathererInitializationData& initData) const {
64-
CBucketGatherer::SBucketGathererInitData bucketGathererInitData{m_SummaryCountFieldName,
64+
const CBucketGatherer::SBucketGathererInitData bucketGathererInitData{m_SummaryCountFieldName,
6565
m_PersonFieldName,
6666
EMPTY_STRING,
6767
EMPTY_STRING,
6868
{},
6969
initData.s_StartTime,
70-
0};
70+
0,
71+
this->resourceMonitor()};
7172
return new CDataGatherer(model_t::E_EventRate, m_SummaryMode,
7273
this->modelParams(), initData.s_PartitionFieldValue,
7374
this->searchKey(), m_Features, bucketGathererInitData);
@@ -77,7 +78,7 @@ CDataGatherer*
7778
CCountingModelFactory::makeDataGatherer(const std::string& partitionFieldValue,
7879
core::CStateRestoreTraverser& traverser) const {
7980
CBucketGatherer::SBucketGathererInitData bucketGathererInitData{
80-
m_SummaryCountFieldName, m_PersonFieldName, EMPTY_STRING, EMPTY_STRING, {}, 0, 0};
81+
m_SummaryCountFieldName, m_PersonFieldName, EMPTY_STRING, EMPTY_STRING, {}, 0, 0, this->resourceMonitor()};
8182
return new CDataGatherer(model_t::E_EventRate, m_SummaryMode,
8283
this->modelParams(), partitionFieldValue,
8384
this->searchKey(), bucketGathererInitData, traverser);

lib/model/CEventRateModelFactory.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ CEventRateModelFactory::makeDataGatherer(const SGathererInitializationData& init
9999
m_ValueFieldName,
100100
m_InfluenceFieldNames,
101101
initData.s_StartTime,
102-
initData.s_SampleOverrideCount};
102+
initData.s_SampleOverrideCount,
103+
this->resourceMonitor()};
103104
return new CDataGatherer(model_t::E_EventRate, m_SummaryMode,
104105
this->modelParams(), initData.s_PartitionFieldValue,
105106
this->searchKey(), m_Features, bucketGathererInitData);
@@ -109,7 +110,7 @@ CDataGatherer*
109110
CEventRateModelFactory::makeDataGatherer(const std::string& partitionFieldValue,
110111
core::CStateRestoreTraverser& traverser) const {
111112
CBucketGatherer::SBucketGathererInitData bucketGathererInitData{
112-
m_SummaryCountFieldName, m_PersonFieldName, EMPTY_STRING, m_ValueFieldName, m_InfluenceFieldNames, 0, 0};
113+
m_SummaryCountFieldName, m_PersonFieldName, EMPTY_STRING, m_ValueFieldName, m_InfluenceFieldNames, 0, 0, this->resourceMonitor()};
113114
return new CDataGatherer(model_t::E_EventRate, m_SummaryMode,
114115
this->modelParams(), partitionFieldValue,
115116
this->searchKey(), bucketGathererInitData, traverser);

lib/model/CEventRatePopulationModelFactory.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ CEventRatePopulationModelFactory::makeDataGatherer(const SGathererInitialization
100100
.s_ValueFieldName=m_ValueFieldName,
101101
.s_InfluenceFieldNames=m_InfluenceFieldNames,
102102
.s_StartTime=initData.s_StartTime,
103-
.s_SampleOverrideCount=0};
103+
.s_SampleOverrideCount=0,
104+
this->resourceMonitor()};
104105
return new CDataGatherer(model_t::E_PopulationEventRate, m_SummaryMode,
105106
this->modelParams(),
106107
initData.s_PartitionFieldValue,
@@ -117,7 +118,7 @@ CEventRatePopulationModelFactory::makeDataGatherer(const std::string& partitionF
117118
.s_ValueFieldName=m_ValueFieldName,
118119
.s_InfluenceFieldNames=m_InfluenceFieldNames,
119120
.s_StartTime=0,
120-
.s_SampleOverrideCount=0};
121+
.s_SampleOverrideCount=0, this->resourceMonitor()};
121122
return new CDataGatherer(model_t::E_PopulationEventRate, m_SummaryMode,
122123
this->modelParams(), partitionFieldValue,
123124
this->searchKey(), bucketGathererInitData, traverser);

lib/model/CMetricModelFactory.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ CMetricModelFactory::makeDataGatherer(const SGathererInitializationData& initDat
9999
m_ValueFieldName,
100100
m_InfluenceFieldNames,
101101
initData.s_StartTime,
102-
initData.s_SampleOverrideCount};
102+
initData.s_SampleOverrideCount,
103+
this->resourceMonitor()};
103104
return new CDataGatherer(model_t::E_Metric, m_SummaryMode, this->modelParams(),
104105
initData.s_PartitionFieldValue, this->searchKey(),
105106
m_Features, bucketGathererInitData);
@@ -109,7 +110,7 @@ CDataGatherer*
109110
CMetricModelFactory::makeDataGatherer(const std::string& partitionFieldValue,
110111
core::CStateRestoreTraverser& traverser) const {
111112
CBucketGatherer::SBucketGathererInitData bucketGathererInitData{
112-
m_SummaryCountFieldName, m_PersonFieldName, EMPTY_STRING, m_ValueFieldName, m_InfluenceFieldNames, 0, 0};
113+
m_SummaryCountFieldName, m_PersonFieldName, EMPTY_STRING, m_ValueFieldName, m_InfluenceFieldNames, 0, 0, this->resourceMonitor()};
113114
return new CDataGatherer(model_t::E_Metric, m_SummaryMode,
114115
this->modelParams(), partitionFieldValue,
115116
this->searchKey(), bucketGathererInitData, traverser);

lib/model/CMetricPopulationModelFactory.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CMetricPopulationModelFactory::makeDataGatherer(const SGathererInitializationDat
9696
m_SummaryCountFieldName, m_PersonFieldName,
9797
m_AttributeFieldName, m_ValueFieldName,
9898
m_InfluenceFieldNames, initData.s_StartTime,
99-
initData.s_SampleOverrideCount};
99+
initData.s_SampleOverrideCount,this->resourceMonitor()};
100100
return new CDataGatherer(model_t::E_PopulationMetric, m_SummaryMode,
101101
this->modelParams(), initData.s_PartitionFieldValue,
102102
this->searchKey(), m_Features, bucketGathererInitData);
@@ -107,7 +107,7 @@ CMetricPopulationModelFactory::makeDataGatherer(const std::string& partitionFiel
107107
core::CStateRestoreTraverser& traverser) const {
108108
CBucketGatherer::SBucketGathererInitData bucketGathererInitData{
109109
m_SummaryCountFieldName, m_PersonFieldName, m_AttributeFieldName, m_ValueFieldName,
110-
m_InfluenceFieldNames, 0, 0};
110+
m_InfluenceFieldNames, 0, 0, this->resourceMonitor()};
111111
return new CDataGatherer(model_t::E_PopulationMetric, m_SummaryMode,
112112
this->modelParams(),
113113
partitionFieldValue, this->searchKey(), bucketGathererInitData, traverser);

lib/model/CModelFactory.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ void CModelFactory::annotationsEnabled(bool enabled) {
294294
void CModelFactory::resourceMonitor(const TResourceMonitorCRef& resourceMonitor) const {
295295
m_ResourceMonitor = resourceMonitor;
296296
}
297+
CModelFactory::TOptionalResourceMonitorCRef CModelFactory::resourceMonitor() const {
298+
return m_ResourceMonitor;
299+
}
297300

298301
CModelFactory::TInterimBucketCorrectorPtr CModelFactory::interimBucketCorrector() const {
299302
TInterimBucketCorrectorPtr result{m_InterimBucketCorrector.lock()};

0 commit comments

Comments
 (0)