@VisibleForTesting void compact() { nextIndex = mergeSameBuckets(values, weights, nextIndex); if (nextIndex <= maxBuckets) { return; } // entries are guaranteed to be sorted as a side-effect of the call to mergeSameBuckets store(mergeBuckets(values, weights, nextIndex, maxBuckets)); }
public void mergeWith(NumericHistogram other) { int count = nextIndex + other.nextIndex; double[] newValues = new double[count]; double[] newWeights = new double[count]; concat(newValues, this.values, this.nextIndex, other.values, other.nextIndex); concat(newWeights, this.weights, this.nextIndex, other.weights, other.nextIndex); count = mergeSameBuckets(newValues, newWeights, count); if (count <= maxBuckets) { // copy back into this.values/this.weights System.arraycopy(newValues, 0, this.values, 0, count); System.arraycopy(newWeights, 0, this.weights, 0, count); nextIndex = count; return; } sort(newValues, newWeights, count); store(mergeBuckets(newValues, newWeights, count, maxBuckets)); }
@VisibleForTesting void compact() { nextIndex = mergeSameBuckets(values, weights, nextIndex); if (nextIndex <= maxBuckets) { return; } // entries are guaranteed to be sorted as a side-effect of the call to mergeSameBuckets store(mergeBuckets(values, weights, nextIndex, maxBuckets)); }
public void mergeWith(NumericHistogram other) { int count = nextIndex + other.nextIndex; double[] newValues = new double[count]; double[] newWeights = new double[count]; concat(newValues, this.values, this.nextIndex, other.values, other.nextIndex); concat(newWeights, this.weights, this.nextIndex, other.weights, other.nextIndex); count = mergeSameBuckets(newValues, newWeights, count); if (count <= maxBuckets) { // copy back into this.values/this.weights System.arraycopy(newValues, 0, this.values, 0, count); System.arraycopy(newWeights, 0, this.weights, 0, count); nextIndex = count; return; } sort(newValues, newWeights, count); store(mergeBuckets(newValues, newWeights, count, maxBuckets)); }