@Override public int hashCode() { int h = getClass().hashCode(); h = 31 * h + Double.hashCode(compression); for (Centroid centroid : centroids()) { h = 31 * h + Double.hashCode(centroid.mean()); h = 31 * h + centroid.count(); } return h; } }
@Override public boolean equals(Object obj) { if (obj == null || obj instanceof TDigestState == false) { return false; } TDigestState that = (TDigestState) obj; if (compression != that.compression) { return false; } Iterator<? extends Centroid> thisCentroids = centroids().iterator(); Iterator<? extends Centroid> thatCentroids = that.centroids().iterator(); while (thisCentroids.hasNext()) { if (thatCentroids.hasNext() == false) { return false; } Centroid thisNext = thisCentroids.next(); Centroid thatNext = thatCentroids.next(); if (thisNext.mean() != thatNext.mean() || thisNext.count() != thatNext.count()) { return false; } } return thatCentroids.hasNext() == false; }
static double computeMedianAbsoluteDeviation(TDigestState valuesSketch) { if (valuesSketch.size() == 0) { return Double.NaN; } else { final double approximateMedian = valuesSketch.quantile(0.5); final TDigestState approximatedDeviationsSketch = new TDigestState(valuesSketch.compression()); valuesSketch.centroids().forEach(centroid -> { final double deviation = Math.abs(approximateMedian - centroid.mean()); approximatedDeviationsSketch.add(deviation, centroid.count()); }); return approximatedDeviationsSketch.quantile(0.5); } }
public static void write(TDigestState state, StreamOutput out) throws IOException { out.writeDouble(state.compression); out.writeVInt(state.centroidCount()); for (Centroid centroid : state.centroids()) { out.writeDouble(centroid.mean()); out.writeVLong(centroid.count()); } }
@Override public int hashCode() { int h = getClass().hashCode(); h = 31 * h + Double.hashCode(compression); for (Centroid centroid : centroids()) { h = 31 * h + Double.hashCode(centroid.mean()); h = 31 * h + centroid.count(); } return h; } }
@Override public int hashCode() { int h = getClass().hashCode(); h = 31 * h + Double.hashCode(compression); for (Centroid centroid : centroids()) { h = 31 * h + Double.hashCode(centroid.mean()); h = 31 * h + centroid.count(); } return h; } }
@Override public boolean equals(Object obj) { if (obj == null || obj instanceof TDigestState == false) { return false; } TDigestState that = (TDigestState) obj; if (compression != that.compression) { return false; } Iterator<? extends Centroid> thisCentroids = centroids().iterator(); Iterator<? extends Centroid> thatCentroids = that.centroids().iterator(); while (thisCentroids.hasNext()) { if (thatCentroids.hasNext() == false) { return false; } Centroid thisNext = thisCentroids.next(); Centroid thatNext = thatCentroids.next(); if (thisNext.mean() != thatNext.mean() || thisNext.count() != thatNext.count()) { return false; } } return thatCentroids.hasNext() == false; }
@Override public boolean equals(Object obj) { if (obj == null || obj instanceof TDigestState == false) { return false; } TDigestState that = (TDigestState) obj; if (compression != that.compression) { return false; } Iterator<? extends Centroid> thisCentroids = centroids().iterator(); Iterator<? extends Centroid> thatCentroids = that.centroids().iterator(); while (thisCentroids.hasNext()) { if (thatCentroids.hasNext() == false) { return false; } Centroid thisNext = thisCentroids.next(); Centroid thatNext = thatCentroids.next(); if (thisNext.mean() != thatNext.mean() || thisNext.count() != thatNext.count()) { return false; } } return thatCentroids.hasNext() == false; }
public static void write(TDigestState state, StreamOutput out) throws IOException { out.writeDouble(state.compression); out.writeVInt(state.centroidCount()); for (Centroid centroid : state.centroids()) { out.writeDouble(centroid.mean()); out.writeVLong(centroid.count()); } }
public static void write(TDigestState state, StreamOutput out) throws IOException { out.writeDouble(state.compression); out.writeVInt(state.centroidCount()); for (Centroid centroid : state.centroids()) { out.writeDouble(centroid.mean()); out.writeVLong(centroid.count()); } }
public static void write(TDigestState state, StreamOutput out) throws IOException { out.writeDouble(state.compression); out.writeVInt(state.centroidCount()); for (Centroid centroid : state.centroids()) { out.writeDouble(centroid.mean()); out.writeVLong(centroid.count()); } }
public static void write(TDigestState state, StreamOutput out) throws IOException { out.writeDouble(state.compression); out.writeVInt(state.centroidCount()); for (Centroid centroid : state.centroids()) { out.writeDouble(centroid.mean()); out.writeVLong(centroid.count()); } }