Skip to content

Commit 2f4a2d9

Browse files
authored
Rename identifier to detectorIndex so that the naming is consistent between C++ and Java (#1251)
1 parent f23d3b8 commit 2f4a2d9

20 files changed

+70
-70
lines changed

include/model/CCountingModelFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class MODEL_EXPORT CCountingModelFactory : public CModelFactory {
103103
//! \name Customization by a specific search
104104
//@{
105105
//! Set the identifier of the search for which this generates models.
106-
virtual void identifier(int identifier);
106+
virtual void detectorIndex(int detectorIndex);
107107

108108
//! Set the name of the field whose values will be counted.
109109
virtual void fieldNames(const std::string& partitionFieldName,
@@ -128,7 +128,7 @@ class MODEL_EXPORT CCountingModelFactory : public CModelFactory {
128128

129129
private:
130130
//! The identifier of the search for which this generates models.
131-
int m_Identifier;
131+
int m_DetectorIndex;
132132

133133
//! Indicates whether the data being gathered are already summarized
134134
//! by an external aggregation process.

include/model/CEventRateModelFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MODEL_EXPORT CEventRateModelFactory final : public CModelFactory {
113113
//! \name Customization by a specific search
114114
//@{
115115
//! Set the identifier of the search for which this generates models.
116-
virtual void identifier(int identifier);
116+
virtual void detectorIndex(int detectorIndex);
117117

118118
//! Set the name of the field whose values will be counted.
119119
virtual void fieldNames(const std::string& partitionFieldName,
@@ -138,7 +138,7 @@ class MODEL_EXPORT CEventRateModelFactory final : public CModelFactory {
138138

139139
private:
140140
//! The identifier of the search for which this generates models.
141-
int m_Identifier = 0;
141+
int m_DetectorIndex = 0;
142142

143143
//! Indicates whether the data being gathered are already summarized
144144
//! by an external aggregation process

include/model/CEventRatePopulationModelFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class MODEL_EXPORT CEventRatePopulationModelFactory final : public CModelFactory
114114
//! \name Customization by a specific search
115115
//@{
116116
//! Set the identifier of the search for which this generates models.
117-
virtual void identifier(int identifier);
117+
virtual void detectorIndex(int detectorIndex);
118118

119119
//! Set the name of the field whose values will be counted.
120120
virtual void fieldNames(const std::string& partitionFieldName,
@@ -140,7 +140,7 @@ class MODEL_EXPORT CEventRatePopulationModelFactory final : public CModelFactory
140140

141141
private:
142142
//! The identifier of the search for which this generates models.
143-
int m_Identifier = 0;
143+
int m_DetectorIndex = 0;
144144

145145
//! Indicates whether the data being gathered are already summarized
146146
//! by an external aggregation process.

include/model/CMetricModelFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MODEL_EXPORT CMetricModelFactory final : public CModelFactory {
113113
//! \name Customization by a specific search
114114
//@{
115115
//! Set the identifier of the search for which this generates models.
116-
virtual void identifier(int identifier);
116+
virtual void detectorIndex(int detectorIndex);
117117

118118
//! Set the name of the field whose values will be counted.
119119
virtual void fieldNames(const std::string& partitionFieldName,
@@ -141,7 +141,7 @@ class MODEL_EXPORT CMetricModelFactory final : public CModelFactory {
141141

142142
private:
143143
//! The identifier of the search for which this generates models.
144-
int m_Identifier = 0;
144+
int m_DetectorIndex = 0;
145145

146146
//! Indicates whether the data being gathered are already summarized
147147
//! by an external aggregation process.

include/model/CMetricPopulationModelFactory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class MODEL_EXPORT CMetricPopulationModelFactory final : public CModelFactory {
114114
//! \name Customization
115115
//@{
116116
//! Set the identifier of the search for which this generates models.
117-
virtual void identifier(int identifier);
117+
virtual void detectorIndex(int detectorIndex);
118118

119119
//! Set the name of the field whose values will be counted.
120120
virtual void fieldNames(const std::string& partitionFieldName,
@@ -145,7 +145,7 @@ class MODEL_EXPORT CMetricPopulationModelFactory final : public CModelFactory {
145145

146146
private:
147147
//! The identifier of the search for which this generates models.
148-
int m_Identifier = 0;
148+
int m_DetectorIndex = 0;
149149

150150
//! Indicates whether the data being gathered are already summarized
151151
//! by an external aggregation process

include/model/CModelFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class MODEL_EXPORT CModelFactory {
267267
//! \name Customization by a specific search
268268
//@{
269269
//! Set the identifier of the search for which this generates models.
270-
virtual void identifier(int identifier) = 0;
270+
virtual void detectorIndex(int detectorIndex) = 0;
271271

272272
//! Set the record field names which will be modeled.
273273
virtual void fieldNames(const std::string& partitionFieldName,

include/model/CSearchKey.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class MODEL_EXPORT CSearchKey {
9999
//!
100100
//! \note Use the pass-by-value-and-swap trick to improve performance
101101
//! when the arguments are temporaries.
102-
explicit CSearchKey(int identifier = 0,
102+
explicit CSearchKey(int detectorIndex = 0,
103103
function_t::EFunction function = function_t::E_IndividualCount,
104104
bool useNull = false,
105105
model_t::EExcludeFrequent excludeFrequent = model_t::E_XF_None,
@@ -134,7 +134,7 @@ class MODEL_EXPORT CSearchKey {
134134
bool operator<(const CSearchKey& rhs) const;
135135

136136
//! Get an identifier for this search.
137-
int identifier() const;
137+
int detectorIndex() const;
138138

139139
//! Get the unique simple counting search key.
140140
//!
@@ -194,7 +194,7 @@ class MODEL_EXPORT CSearchKey {
194194
uint64_t hash() const;
195195

196196
private:
197-
int m_Identifier;
197+
int m_DetectorIndex;
198198
function_t::EFunction m_Function;
199199
bool m_UseNull;
200200
model_t::EExcludeFrequent m_ExcludeFrequent;

lib/api/CAnomalyJob.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ CAnomalyJob::detectorForKey(bool isRestoring,
14711471
<< partition << '\'' << ", time " << time);
14721472
LOG_TRACE(<< "Detector count " << m_Detectors.size());
14731473

1474-
detector = this->makeDetector(key.identifier(), m_ModelConfig, m_Limits,
1474+
detector = this->makeDetector(key.detectorIndex(), m_ModelConfig, m_Limits,
14751475
partition, time, m_ModelConfig.factory(key));
14761476
if (detector == nullptr) {
14771477
// This should never happen as CAnomalyDetectorUtils::makeDetector()

lib/model/CAnomalyDetectorModelConfig.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,11 @@ CAnomalyDetectorModelConfig::factory(const CSearchKey& key) const {
445445
TModelFactoryCPtr result = m_FactoryCache[key];
446446
if (!result) {
447447
result = key.isSimpleCount()
448-
? this->factory(key.identifier(), key.function(), true,
448+
? this->factory(key.detectorIndex(), key.function(), true,
449449
key.excludeFrequent(), key.partitionFieldName(),
450450
key.overFieldName(), key.byFieldName(),
451451
key.fieldName(), key.influenceFieldNames())
452-
: this->factory(key.identifier(), key.function(), key.useNull(),
452+
: this->factory(key.detectorIndex(), key.function(), key.useNull(),
453453
key.excludeFrequent(), key.partitionFieldName(),
454454
key.overFieldName(), key.byFieldName(),
455455
key.fieldName(), key.influenceFieldNames());
@@ -458,7 +458,7 @@ CAnomalyDetectorModelConfig::factory(const CSearchKey& key) const {
458458
}
459459

460460
CAnomalyDetectorModelConfig::TModelFactoryCPtr
461-
CAnomalyDetectorModelConfig::factory(int identifier,
461+
CAnomalyDetectorModelConfig::factory(int detectorIndex,
462462
function_t::EFunction function,
463463
bool useNull,
464464
model_t::EExcludeFrequent excludeFrequent,
@@ -604,7 +604,7 @@ CAnomalyDetectorModelConfig::factory(int identifier,
604604
}
605605

606606
TModelFactoryPtr result(prototype->second->clone());
607-
result->identifier(identifier);
607+
result->detectorIndex(detectorIndex);
608608
TStrVec influences;
609609
influences.reserve(influenceFieldNames.size());
610610
for (const auto& influenceFieldName : influenceFieldNames) {
@@ -616,7 +616,7 @@ CAnomalyDetectorModelConfig::factory(int identifier,
616616
result->excludeFrequent(excludeFrequent);
617617
result->features(features);
618618
result->multivariateByFields(m_MultivariateByFields);
619-
TIntDetectionRuleVecUMapCItr rulesItr = m_DetectionRules.get().find(identifier);
619+
TIntDetectionRuleVecUMapCItr rulesItr = m_DetectionRules.get().find(detectorIndex);
620620
if (rulesItr != m_DetectionRules.get().end()) {
621621
result->detectionRules(TDetectionRuleVecCRef(rulesItr->second));
622622
}

lib/model/CCountingModelFactory.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CCountingModelFactory::CCountingModelFactory(const SModelParams& params,
2525
const TInterimBucketCorrectorWPtr& interimBucketCorrector,
2626
model_t::ESummaryMode summaryMode,
2727
const std::string& summaryCountFieldName)
28-
: CModelFactory(params, interimBucketCorrector), m_Identifier(),
28+
: CModelFactory(params, interimBucketCorrector), m_DetectorIndex(),
2929
m_SummaryMode(summaryMode),
3030
m_SummaryCountFieldName(summaryCountFieldName), m_UseNull(false) {
3131
}
@@ -94,7 +94,7 @@ CCountingModelFactory::defaultCorrelatePrior(model_t::EFeature /*feature*/,
9494

9595
const CSearchKey& CCountingModelFactory::searchKey() const {
9696
if (!m_SearchKeyCache) {
97-
m_SearchKeyCache.emplace(m_Identifier, function_t::function(m_Features),
97+
m_SearchKeyCache.emplace(m_DetectorIndex, function_t::function(m_Features),
9898
m_UseNull, this->modelParams().s_ExcludeFrequent,
9999
"", m_PersonFieldName, "", m_PartitionFieldName);
100100
}
@@ -113,8 +113,8 @@ maths_t::EDataType CCountingModelFactory::dataType() const {
113113
return maths_t::E_IntegerData;
114114
}
115115

116-
void CCountingModelFactory::identifier(int identifier) {
117-
m_Identifier = identifier;
116+
void CCountingModelFactory::detectorIndex(int detectorIndex) {
117+
m_DetectorIndex = detectorIndex;
118118
m_SearchKeyCache.reset();
119119
}
120120

lib/model/CEventRateModelFactory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ CEventRateModelFactory::defaultCorrelatePrior(model_t::EFeature /*feature*/,
209209

210210
const CSearchKey& CEventRateModelFactory::searchKey() const {
211211
if (!m_SearchKeyCache) {
212-
m_SearchKeyCache.emplace(m_Identifier, function_t::function(m_Features),
212+
m_SearchKeyCache.emplace(m_DetectorIndex, function_t::function(m_Features),
213213
m_UseNull, this->modelParams().s_ExcludeFrequent,
214214
m_ValueFieldName, m_PersonFieldName, "",
215215
m_PartitionFieldName, m_InfluenceFieldNames);
@@ -229,8 +229,8 @@ maths_t::EDataType CEventRateModelFactory::dataType() const {
229229
return maths_t::E_IntegerData;
230230
}
231231

232-
void CEventRateModelFactory::identifier(int identifier) {
233-
m_Identifier = identifier;
232+
void CEventRateModelFactory::detectorIndex(int detectorIndex) {
233+
m_DetectorIndex = detectorIndex;
234234
m_SearchKeyCache.reset();
235235
}
236236

lib/model/CEventRatePopulationModelFactory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ CEventRatePopulationModelFactory::defaultCorrelatePrior(model_t::EFeature /*feat
207207

208208
const CSearchKey& CEventRatePopulationModelFactory::searchKey() const {
209209
if (!m_SearchKeyCache) {
210-
m_SearchKeyCache.emplace(m_Identifier, function_t::function(m_Features),
210+
m_SearchKeyCache.emplace(m_DetectorIndex, function_t::function(m_Features),
211211
m_UseNull, this->modelParams().s_ExcludeFrequent,
212212
m_ValueFieldName, m_AttributeFieldName, m_PersonFieldName,
213213
m_PartitionFieldName, m_InfluenceFieldNames);
@@ -227,8 +227,8 @@ maths_t::EDataType CEventRatePopulationModelFactory::dataType() const {
227227
return maths_t::E_IntegerData;
228228
}
229229

230-
void CEventRatePopulationModelFactory::identifier(int identifier) {
231-
m_Identifier = identifier;
230+
void CEventRatePopulationModelFactory::detectorIndex(int detectorIndex) {
231+
m_DetectorIndex = detectorIndex;
232232
m_SearchKeyCache.reset();
233233
}
234234

lib/model/CMetricModelFactory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ CMetricModelFactory::defaultCorrelatePrior(model_t::EFeature /*feature*/,
203203

204204
const CSearchKey& CMetricModelFactory::searchKey() const {
205205
if (!m_SearchKeyCache) {
206-
m_SearchKeyCache.emplace(m_Identifier, function_t::function(m_Features),
206+
m_SearchKeyCache.emplace(m_DetectorIndex, function_t::function(m_Features),
207207
m_UseNull, this->modelParams().s_ExcludeFrequent,
208208
m_ValueFieldName, m_PersonFieldName, "",
209209
m_PartitionFieldName, m_InfluenceFieldNames);
@@ -223,8 +223,8 @@ maths_t::EDataType CMetricModelFactory::dataType() const {
223223
return maths_t::E_ContinuousData;
224224
}
225225

226-
void CMetricModelFactory::identifier(int identifier) {
227-
m_Identifier = identifier;
226+
void CMetricModelFactory::detectorIndex(int detectorIndex) {
227+
m_DetectorIndex = detectorIndex;
228228
m_SearchKeyCache.reset();
229229
}
230230

lib/model/CMetricPopulationModelFactory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ CMetricPopulationModelFactory::defaultCorrelatePrior(model_t::EFeature /*feature
205205

206206
const CSearchKey& CMetricPopulationModelFactory::searchKey() const {
207207
if (!m_SearchKeyCache) {
208-
m_SearchKeyCache.emplace(m_Identifier, function_t::function(m_Features),
208+
m_SearchKeyCache.emplace(m_DetectorIndex, function_t::function(m_Features),
209209
m_UseNull, this->modelParams().s_ExcludeFrequent,
210210
m_ValueFieldName, m_AttributeFieldName, m_PersonFieldName,
211211
m_PartitionFieldName, m_InfluenceFieldNames);
@@ -225,8 +225,8 @@ maths_t::EDataType CMetricPopulationModelFactory::dataType() const {
225225
return maths_t::E_ContinuousData;
226226
}
227227

228-
void CMetricPopulationModelFactory::identifier(int identifier) {
229-
m_Identifier = identifier;
228+
void CMetricPopulationModelFactory::detectorIndex(int detectorIndex) {
229+
m_DetectorIndex = detectorIndex;
230230
m_SearchKeyCache.reset();
231231
}
232232

lib/model/CSearchKey.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CSearchKey::CSearchKey(int identifier,
5959
std::string overFieldName,
6060
std::string partitionFieldName,
6161
const TStrVec& influenceFieldNames)
62-
: m_Identifier(identifier), m_Function(function), m_UseNull(useNull),
62+
: m_DetectorIndex(identifier), m_Function(function), m_UseNull(useNull),
6363
m_ExcludeFrequent(excludeFrequent), m_Hash(0) {
6464
m_FieldName = CStringStore::names().get(fieldName);
6565
m_ByFieldName = CStringStore::names().get(byFieldName);
@@ -72,7 +72,7 @@ CSearchKey::CSearchKey(int identifier,
7272
}
7373

7474
CSearchKey::CSearchKey(core::CStateRestoreTraverser& traverser, bool& successful)
75-
: m_Identifier(0), m_Function(function_t::E_IndividualCount),
75+
: m_DetectorIndex(0), m_Function(function_t::E_IndividualCount),
7676
m_UseNull(false), m_ExcludeFrequent(model_t::E_XF_None), m_Hash(0) {
7777
successful = traverser.traverseSubLevel(
7878
std::bind(&CSearchKey::acceptRestoreTraverser, this, std::placeholders::_1));
@@ -82,7 +82,7 @@ bool CSearchKey::acceptRestoreTraverser(core::CStateRestoreTraverser& traverser)
8282
do {
8383
const std::string& name = traverser.name();
8484
if (name == IDENTIFIER_TAG) {
85-
if (core::CStringUtils::stringToType(traverser.value(), m_Identifier) == false) {
85+
if (core::CStringUtils::stringToType(traverser.value(), m_DetectorIndex) == false) {
8686
LOG_ERROR(<< "Invalid identifier in " << traverser.value());
8787
return false;
8888
}
@@ -127,7 +127,7 @@ bool CSearchKey::acceptRestoreTraverser(core::CStateRestoreTraverser& traverser)
127127
}
128128

129129
void CSearchKey::acceptPersistInserter(core::CStatePersistInserter& inserter) const {
130-
inserter.insertValue(IDENTIFIER_TAG, m_Identifier);
130+
inserter.insertValue(IDENTIFIER_TAG, m_DetectorIndex);
131131
inserter.insertValue(FUNCTION_NAME_TAG, static_cast<int>(m_Function));
132132
inserter.insertValue(USE_NULL_TAG, static_cast<int>(m_UseNull));
133133
inserter.insertValue(EXCLUDE_FREQUENT_TAG, static_cast<int>(m_ExcludeFrequent));
@@ -141,7 +141,7 @@ void CSearchKey::acceptPersistInserter(core::CStatePersistInserter& inserter) co
141141
}
142142

143143
void CSearchKey::swap(CSearchKey& other) {
144-
std::swap(m_Identifier, other.m_Identifier);
144+
std::swap(m_DetectorIndex, other.m_DetectorIndex);
145145
std::swap(m_Function, other.m_Function);
146146
std::swap(m_UseNull, other.m_UseNull);
147147
std::swap(m_ExcludeFrequent, other.m_ExcludeFrequent);
@@ -156,7 +156,7 @@ void CSearchKey::swap(CSearchKey& other) {
156156
bool CSearchKey::operator==(const CSearchKey& rhs) const {
157157
using TStrEqualTo = std::equal_to<std::string>;
158158

159-
return this->hash() == rhs.hash() && m_Identifier == rhs.m_Identifier &&
159+
return this->hash() == rhs.hash() && m_DetectorIndex == rhs.m_DetectorIndex &&
160160
m_Function == rhs.m_Function && m_UseNull == rhs.m_UseNull &&
161161
m_ExcludeFrequent == rhs.m_ExcludeFrequent &&
162162
m_FieldName == rhs.m_FieldName && m_ByFieldName == rhs.m_ByFieldName &&
@@ -178,7 +178,7 @@ bool CSearchKey::operator<(const CSearchKey& rhs) const {
178178
}
179179

180180
if (this->hash() == rhs.hash()) {
181-
if (m_Identifier == rhs.m_Identifier) {
181+
if (m_DetectorIndex == rhs.m_DetectorIndex) {
182182
if (m_Function == rhs.m_Function) {
183183
if (m_UseNull == rhs.m_UseNull) {
184184
if (m_ExcludeFrequent == rhs.m_ExcludeFrequent) {
@@ -226,7 +226,7 @@ bool CSearchKey::operator<(const CSearchKey& rhs) const {
226226
return m_Function < rhs.m_Function;
227227
}
228228

229-
return m_Identifier < rhs.m_Identifier;
229+
return m_DetectorIndex < rhs.m_DetectorIndex;
230230
}
231231

232232
return this->hash() < rhs.hash();
@@ -295,8 +295,8 @@ std::string CSearchKey::debug() const {
295295
return strm.str();
296296
}
297297

298-
int CSearchKey::identifier() const {
299-
return m_Identifier;
298+
int CSearchKey::detectorIndex() const {
299+
return m_DetectorIndex;
300300
}
301301

302302
function_t::EFunction CSearchKey::function() const {
@@ -342,7 +342,7 @@ uint64_t CSearchKey::hash() const {
342342
}
343343
m_Hash = m_UseNull ? 1 : 0;
344344
m_Hash = 4 * m_Hash + static_cast<uint64_t>(m_ExcludeFrequent);
345-
m_Hash = core::CHashing::hashCombine(m_Hash, static_cast<uint64_t>(m_Identifier));
345+
m_Hash = core::CHashing::hashCombine(m_Hash, static_cast<uint64_t>(m_DetectorIndex));
346346
m_Hash = core::CHashing::hashCombine(m_Hash, static_cast<uint64_t>(m_Function));
347347
m_Hash = maths::CChecksum::calculate(m_Hash, *m_FieldName);
348348
m_Hash = maths::CChecksum::calculate(m_Hash, *m_ByFieldName);
@@ -357,7 +357,7 @@ std::ostream& operator<<(std::ostream& strm, const CSearchKey& key) {
357357
// The format for this is very similar to the format used by toCue() at the
358358
// time of writing. However, do NOT combine the code because the intention
359359
// is to simplify toCue() in the future.
360-
strm << key.m_Identifier << "==" << function_t::print(key.m_Function) << '/'
360+
strm << key.m_DetectorIndex << "==" << function_t::print(key.m_Function) << '/'
361361
<< (key.m_UseNull ? '1' : '0') << '/' << static_cast<int>(key.m_ExcludeFrequent)
362362
<< '/' << *key.m_FieldName << '/' << *key.m_ByFieldName << '/'
363363
<< *key.m_OverFieldName << '/' << *key.m_PartitionFieldName << '/';

0 commit comments

Comments
 (0)