Loading cmds/statsd/src/condition/CombinationConditionTracker.cpp +5 −8 Original line number Original line Diff line number Diff line Loading @@ -141,17 +141,14 @@ void CombinationConditionTracker::evaluateCondition( ConditionState newCondition = ConditionState newCondition = evaluateCombinationCondition(mChildren, mLogicalOperation, nonSlicedConditionCache); evaluateCombinationCondition(mChildren, mLogicalOperation, nonSlicedConditionCache); if (!mSliced) { if (!mSliced) { bool nonSlicedChanged = (mUnSlicedPartCondition != newCondition); mUnSlicedPartCondition = newCondition; bool nonSlicedChanged = (mNonSlicedConditionState != newCondition); nonSlicedConditionCache[mIndex] = mUnSlicedPartCondition; mNonSlicedConditionState = newCondition; nonSlicedConditionCache[mIndex] = mNonSlicedConditionState; conditionChangedCache[mIndex] = nonSlicedChanged; conditionChangedCache[mIndex] = nonSlicedChanged; mUnSlicedPart = newCondition; } else { } else { mUnSlicedPart = evaluateCombinationCondition( mUnSlicedPartCondition = evaluateCombinationCondition(mUnSlicedChildren, mLogicalOperation, mUnSlicedChildren, mLogicalOperation, nonSlicedConditionCache); nonSlicedConditionCache); for (const int childIndex : mChildren) { for (const int childIndex : mChildren) { // If any of the sliced condition in children condition changes, the combination // If any of the sliced condition in children condition changes, the combination Loading cmds/statsd/src/condition/ConditionTracker.h +11 −9 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,7 @@ public: mIndex(index), mIndex(index), mInitialized(false), mInitialized(false), mTrackerIndex(), mTrackerIndex(), mNonSlicedConditionState(ConditionState::kUnknown), mUnSlicedPartCondition(ConditionState::kUnknown), mSliced(false){}; mSliced(false){}; virtual ~ConditionTracker(){}; virtual ~ConditionTracker(){}; Loading Loading @@ -72,11 +72,6 @@ public: std::vector<ConditionState>& conditionCache, std::vector<ConditionState>& conditionCache, std::vector<bool>& conditionChanged) = 0; std::vector<bool>& conditionChanged) = 0; // Return the current condition state. virtual ConditionState isConditionMet() const { return mNonSlicedConditionState; }; // Query the condition with parameters. // Query the condition with parameters. // [conditionParameters]: a map from condition name to the HashableDimensionKey to query the // [conditionParameters]: a map from condition name to the HashableDimensionKey to query the // condition. // condition. Loading Loading @@ -125,8 +120,9 @@ public: const std::vector<sp<ConditionTracker>>& allConditions, const std::vector<sp<ConditionTracker>>& allConditions, const vector<Matcher>& dimensions) const = 0; const vector<Matcher>& dimensions) const = 0; // Return the current condition state of the unsliced part of the condition. inline ConditionState getUnSlicedPartConditionState() const { inline ConditionState getUnSlicedPartConditionState() const { return mUnSlicedPart; return mUnSlicedPartCondition; } } protected: protected: Loading @@ -141,10 +137,16 @@ protected: // the list of LogMatchingTracker index that this ConditionTracker uses. // the list of LogMatchingTracker index that this ConditionTracker uses. std::set<int> mTrackerIndex; 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; bool mSliced; ConditionState mUnSlicedPart; }; }; } // namespace statsd } // namespace statsd Loading cmds/statsd/src/condition/SimpleConditionTracker.cpp +0 −14 Original line number Original line Diff line number Diff line Loading @@ -85,12 +85,6 @@ SimpleConditionTracker::SimpleConditionTracker( mInitialValue = ConditionState::kUnknown; mInitialValue = ConditionState::kUnknown; } } mNonSlicedConditionState = mInitialValue; if (!mSliced) { mUnSlicedPart = mInitialValue; } mInitialized = true; mInitialized = true; } } Loading Loading @@ -141,9 +135,6 @@ void SimpleConditionTracker::handleStopAll(std::vector<ConditionState>& conditio mInitialValue = ConditionState::kFalse; mInitialValue = ConditionState::kFalse; mSlicedConditionState.clear(); mSlicedConditionState.clear(); conditionCache[mIndex] = ConditionState::kFalse; conditionCache[mIndex] = ConditionState::kFalse; if (!mSliced) { mUnSlicedPart = ConditionState::kFalse; } } } bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { Loading Loading @@ -305,9 +296,7 @@ void SimpleConditionTracker::evaluateCondition( conditionCache[mIndex] = conditionCache[mIndex] = itr->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; itr->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; } } mUnSlicedPart = conditionCache[mIndex]; } } return; return; } } Loading @@ -333,9 +322,6 @@ void SimpleConditionTracker::evaluateCondition( } } conditionCache[mIndex] = overallState; conditionCache[mIndex] = overallState; conditionChangedCache[mIndex] = overallChanged; conditionChangedCache[mIndex] = overallChanged; if (!mSliced) { mUnSlicedPart = overallState; } } } void SimpleConditionTracker::isConditionMet( void SimpleConditionTracker::isConditionMet( Loading Loading
cmds/statsd/src/condition/CombinationConditionTracker.cpp +5 −8 Original line number Original line Diff line number Diff line Loading @@ -141,17 +141,14 @@ void CombinationConditionTracker::evaluateCondition( ConditionState newCondition = ConditionState newCondition = evaluateCombinationCondition(mChildren, mLogicalOperation, nonSlicedConditionCache); evaluateCombinationCondition(mChildren, mLogicalOperation, nonSlicedConditionCache); if (!mSliced) { if (!mSliced) { bool nonSlicedChanged = (mUnSlicedPartCondition != newCondition); mUnSlicedPartCondition = newCondition; bool nonSlicedChanged = (mNonSlicedConditionState != newCondition); nonSlicedConditionCache[mIndex] = mUnSlicedPartCondition; mNonSlicedConditionState = newCondition; nonSlicedConditionCache[mIndex] = mNonSlicedConditionState; conditionChangedCache[mIndex] = nonSlicedChanged; conditionChangedCache[mIndex] = nonSlicedChanged; mUnSlicedPart = newCondition; } else { } else { mUnSlicedPart = evaluateCombinationCondition( mUnSlicedPartCondition = evaluateCombinationCondition(mUnSlicedChildren, mLogicalOperation, mUnSlicedChildren, mLogicalOperation, nonSlicedConditionCache); nonSlicedConditionCache); for (const int childIndex : mChildren) { for (const int childIndex : mChildren) { // If any of the sliced condition in children condition changes, the combination // If any of the sliced condition in children condition changes, the combination Loading
cmds/statsd/src/condition/ConditionTracker.h +11 −9 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,7 @@ public: mIndex(index), mIndex(index), mInitialized(false), mInitialized(false), mTrackerIndex(), mTrackerIndex(), mNonSlicedConditionState(ConditionState::kUnknown), mUnSlicedPartCondition(ConditionState::kUnknown), mSliced(false){}; mSliced(false){}; virtual ~ConditionTracker(){}; virtual ~ConditionTracker(){}; Loading Loading @@ -72,11 +72,6 @@ public: std::vector<ConditionState>& conditionCache, std::vector<ConditionState>& conditionCache, std::vector<bool>& conditionChanged) = 0; std::vector<bool>& conditionChanged) = 0; // Return the current condition state. virtual ConditionState isConditionMet() const { return mNonSlicedConditionState; }; // Query the condition with parameters. // Query the condition with parameters. // [conditionParameters]: a map from condition name to the HashableDimensionKey to query the // [conditionParameters]: a map from condition name to the HashableDimensionKey to query the // condition. // condition. Loading Loading @@ -125,8 +120,9 @@ public: const std::vector<sp<ConditionTracker>>& allConditions, const std::vector<sp<ConditionTracker>>& allConditions, const vector<Matcher>& dimensions) const = 0; const vector<Matcher>& dimensions) const = 0; // Return the current condition state of the unsliced part of the condition. inline ConditionState getUnSlicedPartConditionState() const { inline ConditionState getUnSlicedPartConditionState() const { return mUnSlicedPart; return mUnSlicedPartCondition; } } protected: protected: Loading @@ -141,10 +137,16 @@ protected: // the list of LogMatchingTracker index that this ConditionTracker uses. // the list of LogMatchingTracker index that this ConditionTracker uses. std::set<int> mTrackerIndex; 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; bool mSliced; ConditionState mUnSlicedPart; }; }; } // namespace statsd } // namespace statsd Loading
cmds/statsd/src/condition/SimpleConditionTracker.cpp +0 −14 Original line number Original line Diff line number Diff line Loading @@ -85,12 +85,6 @@ SimpleConditionTracker::SimpleConditionTracker( mInitialValue = ConditionState::kUnknown; mInitialValue = ConditionState::kUnknown; } } mNonSlicedConditionState = mInitialValue; if (!mSliced) { mUnSlicedPart = mInitialValue; } mInitialized = true; mInitialized = true; } } Loading Loading @@ -141,9 +135,6 @@ void SimpleConditionTracker::handleStopAll(std::vector<ConditionState>& conditio mInitialValue = ConditionState::kFalse; mInitialValue = ConditionState::kFalse; mSlicedConditionState.clear(); mSlicedConditionState.clear(); conditionCache[mIndex] = ConditionState::kFalse; conditionCache[mIndex] = ConditionState::kFalse; if (!mSliced) { mUnSlicedPart = ConditionState::kFalse; } } } bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { bool SimpleConditionTracker::hitGuardRail(const HashableDimensionKey& newKey) { Loading Loading @@ -305,9 +296,7 @@ void SimpleConditionTracker::evaluateCondition( conditionCache[mIndex] = conditionCache[mIndex] = itr->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; itr->second > 0 ? ConditionState::kTrue : ConditionState::kFalse; } } mUnSlicedPart = conditionCache[mIndex]; } } return; return; } } Loading @@ -333,9 +322,6 @@ void SimpleConditionTracker::evaluateCondition( } } conditionCache[mIndex] = overallState; conditionCache[mIndex] = overallState; conditionChangedCache[mIndex] = overallChanged; conditionChangedCache[mIndex] = overallChanged; if (!mSliced) { mUnSlicedPart = overallState; } } } void SimpleConditionTracker::isConditionMet( void SimpleConditionTracker::isConditionMet( Loading