public virtual void IncrAllCounters(CounterGroupBase <C> other) { if (Preconditions.CheckNotNull(other.GetUnderlyingGroup(), "other group") is FileSystemCounterGroup <object> ) { foreach (Counter counter in other) { FileSystemCounterGroup.FSCounter c = (FileSystemCounterGroup.FSCounter)((Counter) counter).GetUnderlyingCounter(); FindCounter(c.scheme, c.key).Increment(counter.GetValue()); } } }
public virtual void AddCounter(C counter) { C ours; if (counter is FileSystemCounterGroup.FSCounter) { FileSystemCounterGroup.FSCounter c = (FileSystemCounterGroup.FSCounter)counter; ours = FindCounter(c.scheme, c.key); } else { ours = FindCounter(counter.GetName()); } if (ours != null) { ours.SetValue(counter.GetValue()); } }
/// <summary>FileSystemGroup ::= #scheme (scheme #counter (key value)*)</summary> /// <exception cref="System.IO.IOException"/> public virtual void Write(DataOutput @out) { WritableUtils.WriteVInt(@out, map.Count); // #scheme foreach (KeyValuePair <string, object[]> entry in map) { WritableUtils.WriteString(@out, entry.Key); // scheme // #counter for the above scheme WritableUtils.WriteVInt(@out, NumSetCounters(entry.Value)); foreach (object counter in entry.Value) { if (counter == null) { continue; } FileSystemCounterGroup.FSCounter c = (FileSystemCounterGroup.FSCounter)((Counter) counter).GetUnderlyingCounter(); WritableUtils.WriteVInt(@out, (int)(c.key)); // key WritableUtils.WriteVLong(@out, c.GetValue()); } } }