Add StateTracker.
StateTracker is a special condition tracker that's based on a state atom.
State atoms are annotated in atoms.proto.
The rules for StateTracker:
1. must not have "stop". must have "dimension"
2. must be based on a state atom.
3. it must have the all primary fields and the exclusive state field in its dimension.
For example UidProcessStateTracker, will have output dimension {uid, state}.
Test: unit tests added.
Change-Id: I6b77e58e9fabe61f7326daf929577d8b2cfbf27b
diff --git a/cmds/statsd/src/FieldValue.h b/cmds/statsd/src/FieldValue.h
index b0e2c43..621d0be9 100644
--- a/cmds/statsd/src/FieldValue.h
+++ b/cmds/statsd/src/FieldValue.h
@@ -41,6 +41,7 @@
inline int32_t getSimpleField(size_t field) {
return ((int32_t)field << 8 * 2);
}
+
/**
* Field is a wrapper class for 2 integers that represents the field of a log element in its Atom
* proto.
@@ -201,9 +202,9 @@
* }
*
* We translate the FieldMatcher into a Field, and mask
- * First: [Matcher Field] 0x02010101 [Mask]0xffff7fff
- * Last: [Matcher Field] 0x02018001 [Mask]0xffff80ff
- * Any: [Matcher Field] 0x02010001 [Mask]0xffff00ff
+ * First: [Matcher Field] 0x02010101 [Mask]0xff7f7f7f
+ * Last: [Matcher Field] 0x02018001 [Mask]0xff7f807f
+ * Any: [Matcher Field] 0x02010001 [Mask]0xff7f007f
*
* [To match a log Field with a Matcher] we apply the bit mask to the log Field and check if
* the result is equal to the Matcher Field. That's a bit wise AND operation + check if 2 ints are
@@ -235,9 +236,17 @@
inline bool operator!=(const Matcher& that) const {
return mMatcher != that.getMatcher() || mMask != that.getMask();
- };
+ }
+
+ inline bool operator==(const Matcher& that) const {
+ return mMatcher == that.mMatcher && mMask == that.mMask;
+ }
};
+inline Matcher getSimpleMatcher(int32_t tag, size_t field) {
+ return Matcher(Field(tag, getSimpleField(field)), 0xff7f0000);
+}
+
/**
* A wrapper for a union type to contain multiple types of values.
*