Reduce statsd log data size.

1. Hash the strings in metric dimensions.
2. Optimize the timestamp encoding in bucket.
   Use bucket num for full bucket and millis for
   partial bucket.
3. Encode the dimension path per metric and avoid
   deduping it across dimensons.

Test: statsd test
Change-Id: I18f69654de85edb21a9c835c73edead756295e05
BUG: b/77813755
diff --git a/cmds/statsd/src/stats_log_util.h b/cmds/statsd/src/stats_log_util.h
index 9722050..b8f6850 100644
--- a/cmds/statsd/src/stats_log_util.h
+++ b/cmds/statsd/src/stats_log_util.h
@@ -28,9 +28,17 @@
 
 void writeFieldValueTreeToStream(int tagId, const std::vector<FieldValue>& values,
                                  util::ProtoOutputStream* protoOutput);
-void writeDimensionToProto(const HashableDimensionKey& dimension,
+void writeDimensionToProto(const HashableDimensionKey& dimension, std::set<string> *str_set,
                            util::ProtoOutputStream* protoOutput);
 
+void writeDimensionLeafNodesToProto(const HashableDimensionKey& dimension,
+                                    const int dimensionLeafFieldId,
+                                    std::set<string> *str_set,
+                                    util::ProtoOutputStream* protoOutput);
+
+void writeDimensionPathToProto(const std::vector<Matcher>& fieldMatchers,
+                               util::ProtoOutputStream* protoOutput);
+
 // Convert the TimeUnit enum to the bucket size in millis with a guardrail on
 // bucket size.
 int64_t TimeUnitToBucketSizeInMillisGuardrailed(int uid, TimeUnit unit);
@@ -56,6 +64,10 @@
 // Gets the wall clock timestamp in seconds.
 int64_t getWallClockSec();
 
+int64_t NanoToMillis(const int64_t nano);
+
+int64_t MillisToNano(const int64_t millis);
+
 // Helper function to write PulledAtomStats to ProtoOutputStream
 void writePullerStatsToStream(const std::pair<int, StatsdStats::PulledAtomStats>& pair,
                               util::ProtoOutputStream* protoOutput);