diff options
| author | 2020-05-30 11:06:42 +0000 | |
|---|---|---|
| committer | 2020-05-30 11:06:42 +0000 | |
| commit | 9d94c092ed00c5ed5447b967b7fbbf70546cab18 (patch) | |
| tree | 4a759f55ffe62656ec26aeda9fe2828a9d1227ee | |
| parent | 1d76e461166b92f4bbd615826a8903fabe54e9ed (diff) | |
| parent | fe46973f26ae2d6505f5dbd60f2850205be53860 (diff) | |
Merge "Clean up ConditionTracker variables for tracking unsliced condition" into rvc-dev
| -rw-r--r-- | cmds/statsd/src/condition/CombinationConditionTracker.cpp | 13 | ||||
| -rw-r--r-- | cmds/statsd/src/condition/ConditionTracker.h | 20 | ||||
| -rw-r--r-- | cmds/statsd/src/condition/SimpleConditionTracker.cpp | 14 |
3 files changed, 16 insertions, 31 deletions
diff --git a/cmds/statsd/src/condition/CombinationConditionTracker.cpp b/cmds/statsd/src/condition/CombinationConditionTracker.cpp index 2d7f912dac84..c829ccd11ec9 100644 --- a/cmds/statsd/src/condition/CombinationConditionTracker.cpp +++ b/cmds/statsd/src/condition/CombinationConditionTracker.cpp @@ -141,17 +141,14 @@ void CombinationConditionTracker::evaluateCondition( ConditionState newCondition = evaluateCombinationCondition(mChildren, mLogicalOperation, nonSlicedConditionCache); if (!mSliced) { + bool nonSlicedChanged = (mUnSlicedPartCondition != newCondition); + mUnSlicedPartCondition = newCondition; - bool nonSlicedChanged = (mNonSlicedConditionState != newCondition); - mNonSlicedConditionState = newCondition; - - nonSlicedConditionCache[mIndex] = mNonSlicedConditionState; - + nonSlicedConditionCache[mIndex] = mUnSlicedPartCondition; conditionChangedCache[mIndex] = nonSlicedChanged; - mUnSlicedPart = newCondition; } else { - mUnSlicedPart = evaluateCombinationCondition( - mUnSlicedChildren, mLogicalOperation, nonSlicedConditionCache); + mUnSlicedPartCondition = evaluateCombinationCondition(mUnSlicedChildren, mLogicalOperation, + nonSlicedConditionCache); for (const int childIndex : mChildren) { // If any of the sliced condition in children condition changes, the combination diff --git a/cmds/statsd/src/condition/ConditionTracker.h b/cmds/statsd/src/condition/ConditionTracker.h index 26de88860ab4..f9a2c344c346 100644 --- a/cmds/statsd/src/condition/ConditionTracker.h +++ b/cmds/statsd/src/condition/ConditionTracker.h @@ -36,7 +36,7 @@ public: mIndex(index), mInitialized(false), mTrackerIndex(), - mNonSlicedConditionState(ConditionState::kUnknown), + mUnSlicedPartCondition(ConditionState::kUnknown), mSliced(false){}; virtual ~ConditionTracker(){}; @@ -72,11 +72,6 @@ public: std::vector<ConditionState>& conditionCache, std::vector<bool>& conditionChanged) = 0; - // Return the current condition state. - virtual ConditionState isConditionMet() const { - return mNonSlicedConditionState; - }; - // Query the condition with parameters. // [conditionParameters]: a map from condition name to the HashableDimensionKey to query the // condition. @@ -125,8 +120,9 @@ public: const std::vector<sp<ConditionTracker>>& allConditions, const vector<Matcher>& dimensions) const = 0; + // Return the current condition state of the unsliced part of the condition. inline ConditionState getUnSlicedPartConditionState() const { - return mUnSlicedPart; + return mUnSlicedPartCondition; } protected: @@ -141,10 +137,16 @@ protected: // the list of LogMatchingTracker index that this ConditionTracker uses. std::set<int> mTrackerIndex; - ConditionState mNonSlicedConditionState; + // This variable is only used for CombinationConditionTrackers. + // SimpleConditionTrackers technically don't have an unsliced part because + // they are either sliced or unsliced. + // + // CombinationConditionTrackers have multiple children ConditionTrackers + // that can be a mixture of sliced or unsliced. This tracks the + // condition of the unsliced part of the combination condition. + ConditionState mUnSlicedPartCondition; bool mSliced; - ConditionState mUnSlicedPart; }; } // namespace statsd diff --git a/cmds/statsd/src/condition/SimpleConditionTracker.cpp b/cmds/statsd/src/condition/SimpleConditionTracker.cpp index 61760f3e29b2..f23ec50abb50 100644 --- a/cmds/statsd/src/condition/SimpleConditionTracker.cpp +++ b/cmds/statsd/src/condition/SimpleConditionTracker.cpp @@ -85,12 +85,6 @@ SimpleConditionTracker::SimpleConditionTracker( mInitialValue = ConditionState::kUnknown; } - mNonSlicedConditionState = mInitialValue; - - if (!mSliced) { - mUnSlicedPart = mInitialValue; - } - mInitialized = true; } @@ -141,9 +135,6 @@ void SimpleConditionTracker::handleStopAll(std::vector<ConditionState>& conditio mInitialValue = ConditionState::kFalse; mSlicedConditionState.clear(); conditionCache[mIndex] = ConditionState::kFalse; - if (!mSliced) { - mUnSlicedPart = ConditionState::kFalse; - } } bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { @@ -305,9 +296,7 @@ void SimpleConditionTracker::evaluateCondition( conditionCache[mIndex] = itr->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; } - mUnSlicedPart = conditionCache[mIndex]; } - return; } @@ -333,9 +322,6 @@ void SimpleConditionTracker::evaluateCondition( } conditionCache[mIndex] = overallState; conditionChangedCache[mIndex] = overallChanged; - if (!mSliced) { - mUnSlicedPart = overallState; - } } void SimpleConditionTracker::isConditionMet( |