diff options
| author | 2018-02-15 18:45:00 -0800 | |
|---|---|---|
| committer | 2018-02-15 18:45:00 -0800 | |
| commit | bcc71c55c77d3ed36152ecc1ce691f16ad102312 (patch) | |
| tree | f31a4abd0a86516a6c822ed8a99d0996c6f22ce5 | |
| parent | 100d494bae64ca1cafda06a66b7ef91df90ff833 (diff) | |
Resupport long compare
In ag/3554499 we made it so that comparisons of longs was supported.
That support was apparantly deleted by accident during a refactoring of
code, so this adds it back.
Bug: 73509837
Test: it gets used in run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.alert.AnomalyDetectionTests#testCountAnomalyDetection
Change-Id: I3dbe7da61bbfb3e9982fd1e0cc7d4658b0168690
| -rw-r--r-- | cmds/statsd/src/matchers/matcher_util.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cmds/statsd/src/matchers/matcher_util.cpp b/cmds/statsd/src/matchers/matcher_util.cpp index 944764bece8a..461200905a25 100644 --- a/cmds/statsd/src/matchers/matcher_util.cpp +++ b/cmds/statsd/src/matchers/matcher_util.cpp @@ -233,6 +233,11 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher, (matcher.eq_int() == values[i].mValue.int_value)) { return true; } + // eq_int covers both int and long. + if (values[i].mValue.getType() == LONG && + (matcher.eq_int() == values[i].mValue.long_value)) { + return true; + } } return false; case FieldValueMatcher::ValueMatcherCase::kLtInt: @@ -241,6 +246,11 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher, (values[i].mValue.int_value < matcher.lt_int())) { return true; } + // lt_int covers both int and long. + if (values[i].mValue.getType() == LONG && + (values[i].mValue.long_value < matcher.lt_int())) { + return true; + } } return false; case FieldValueMatcher::ValueMatcherCase::kGtInt: @@ -249,6 +259,11 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher, (values[i].mValue.int_value > matcher.gt_int())) { return true; } + // gt_int covers both int and long. + if (values[i].mValue.getType() == LONG && + (values[i].mValue.long_value > matcher.gt_int())) { + return true; + } } return false; case FieldValueMatcher::ValueMatcherCase::kLtFloat: @@ -273,6 +288,11 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher, (values[i].mValue.int_value <= matcher.lte_int())) { return true; } + // lte_int covers both int and long. + if (values[i].mValue.getType() == LONG && + (values[i].mValue.long_value <= matcher.lte_int())) { + return true; + } } return false; case FieldValueMatcher::ValueMatcherCase::kGteInt: @@ -281,6 +301,11 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher, (values[i].mValue.int_value >= matcher.gte_int())) { return true; } + // gte_int covers both int and long. + if (values[i].mValue.getType() == LONG && + (values[i].mValue.long_value >= matcher.gte_int())) { + return true; + } } return false; default: |