Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3739df05 authored by Olivier Gaillard's avatar Olivier Gaillard Committed by Android (Google) Code Review
Browse files

Merge "Mark bucket as invalid when the condition was unknown at the start of the bucket."

parents 973e0e77 0a36f579
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -355,12 +355,11 @@ void ValueMetricProducer::onConditionChangedLocked(const bool condition,

    flushIfNeededLocked(eventTimeNs);

    if (mCondition != ConditionState::kUnknown) {
        // Pull on condition changes.
        bool conditionChanged = mCondition != condition;
    bool unknownToFalse = mCondition == ConditionState::kUnknown
            && condition == ConditionState::kFalse;
        // We do not need to pull when we go from unknown to false.
    if (mIsPulled && conditionChanged && !unknownToFalse) {
        if (mIsPulled && conditionChanged) {
            pullAndMatchEventsLocked(eventTimeNs);
        }

@@ -369,7 +368,12 @@ void ValueMetricProducer::onConditionChangedLocked(const bool condition,
        if (mUseDiff && mCondition == ConditionState::kTrue && condition == ConditionState::kFalse) {
            resetBase();
        }

    } else {
        // If the condition was unknown, we mark the bucket as invalid since the bucket will contain
        // partial data. For instance, the condition change might happen close to the end of the
        // bucket and we might miss lots of data.
        invalidateCurrentBucket();
    }
    mCondition = condition ? ConditionState::kTrue : ConditionState::kFalse;
}

+2 −0
Original line number Diff line number Diff line
@@ -255,6 +255,8 @@ private:
    FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onConditionChanged);
    FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onBucketBoundary);
    FRIEND_TEST(ValueMetricProducerTest, TestPartialResetOnBucketBoundaries);
    FRIEND_TEST(ValueMetricProducerTest, TestBucketIncludingUnknownConditionIsInvalid);
    friend class ValueMetricProducerTestHelper;
};

}  // namespace statsd
+249 −345

File changed.

Preview size limit exceeded, changes collapsed.