+func (EmptyStat) isStat() {}
+
+func (s ScalarStat) IsZero() bool {
+ return s == 0
+}
+
+func (s ScalarStat) Type() StatType {
+ return ScalarIndex
+}
+
+func (s ErrorStat) IsZero() bool {
+ if s == nil {
+ return true
+ }
+ for _, ss := range s {
+ if ss != 0 {
+ return false
+ }
+ }
+ return true
+}
+
+func (s ErrorStat) Type() StatType {
+ return ErrorIndex
+}
+
+func (s SimpleCounterStat) IsZero() bool {
+ if s == nil {
+ return true
+ }
+ for _, ss := range s {
+ for _, sss := range ss {
+ if sss != 0 {
+ return false
+ }
+ }
+ }
+ return true
+}
+
+func (s SimpleCounterStat) Type() StatType {
+ return SimpleCounterVector
+}
+
+func (s CombinedCounterStat) IsZero() bool {
+ if s == nil {
+ return true
+ }
+ for _, ss := range s {
+ if ss == nil {
+ return true
+ }
+ for _, sss := range ss {
+ if sss[0] != 0 || sss[1] != 0 {
+ return false
+ }
+ }
+ }
+ return true
+}
+
+func (s CombinedCounterStat) Type() StatType {
+ return CombinedCounterVector
+}
+
+func (s NameStat) IsZero() bool {
+ if s == nil {
+ return true
+ }
+ for _, ss := range s {
+ if len(ss) > 0 {
+ return false
+ }
+ }
+ return true
+}
+
+func (s NameStat) Type() StatType {
+ return NameVector
+}
+
+func (s EmptyStat) IsZero() bool {
+ return true
+}
+
+func (s EmptyStat) Type() StatType {
+ return Empty
+}
+
+// ReduceSimpleCounterStatIndex returns reduced SimpleCounterStat s for index i.
+func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64 {
+ var val uint64
+ for _, w := range s {
+ val += uint64(w[i])
+ }
+ return val
+}
+
+// ReduceCombinedCounterStatIndex returns reduced CombinedCounterStat s for index i.
+func ReduceCombinedCounterStatIndex(s CombinedCounterStat, i int) [2]uint64 {
+ var val [2]uint64
+ for _, w := range s {
+ val[0] += w[i][0]
+ val[1] += w[i][1]
+ }
+ return val
+}