@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (getClass() != obj.getClass()) return false; GaugeMetricValue that = (GaugeMetricValue) obj; return (Double.compare(that.max, max) == 0) && (Double.compare(that.min, min) == 0) && (n == that.n) && (Double.compare(that.sum, sum) == 0) && (Double.compare(that.sumOfSquares, sumOfSquares) == 0) && ObjectUtil.typedEquals(getHistogram(), that.getHistogram()) && ObjectUtil.typedEquals(getRange(), that.getRange()) ; }
@Override protected Box createBoxForValue(GaugeMetricValue value) { return new Box(value.getN(), value.getMean(), value.getRange()); } }
public void toData(DataOutput dataOutput) throws IOException { super.toData(serialVersionUID, dataOutput); dataOutput.writeInt(slots.size()); int usedSlots = 0; for (GaugeMetricValue v : slots) { if (v != null) usedSlots++; } dataOutput.writeInt(usedSlots); int idx = -1; for (GaugeMetricValue v : slots) { idx++; if (v == null) { continue; } dataOutput.writeInt(idx); dataOutput.writeDouble(v.getMin()); dataOutput.writeDouble(v.getMax()); dataOutput.writeLong(v.getN()); dataOutput.writeDouble(v.getSum()); dataOutput.writeDouble(v.getSumOfSquares()); dataOutput.writeLong(v.getRange().getStart()); SparseHistogram histo = v.getHistogram(); dataOutput.writeInt(histo.getBins().size()); for (IndexedBin bin : histo.getBins()) { dataOutput.writeInt(bin.getBinNumber()); dataOutput.writeLong(bin.getCount()); } } }
@Override public int hashCode() { int result=MathUtil.hashValue(sumOfSquares); result = 31 * result + MathUtil.hashValue(min); result = 31 * result + MathUtil.hashValue(max); result = 31 * result + MathUtil.hashValue(n); result = 31 * result + MathUtil.hashValue(sum); result = 31 * result + ObjectUtil.hashCode(getRange()); result = 31 * result + ObjectUtil.hashCode(getHistogram()); return result; }