@Override void incrementIterationLevel() { currentStepHighestValueReportingLevel += valueUnitsPerBucket; currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
/** * Determine if two values are equivalent with the histogram's resolution. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value1 first value to compare * @param value2 second value to compare * @return True if values are equivalent with the histogram's resolution. */ public boolean valuesAreEquivalent(final long value1, final long value2) { return (lowestEquivalentValue(value1) == lowestEquivalentValue(value2)); }
/** * Get the lowest recorded non-zero value level in the histogram. If the histogram has no recorded values, * the value returned is undefined. * * @return the lowest recorded non-zero value level in the histogram */ public long getMinNonZeroValue() { return (minNonZeroValue == Long.MAX_VALUE) ? Long.MAX_VALUE : lowestEquivalentValue(minNonZeroValue); }
@Override void incrementIterationLevel() { nextValueReportingLevel *= logBase; this.currentStepHighestValueReportingLevel = ((long)nextValueReportingLevel) - 1; currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
@Override public boolean hasNext() { if (super.hasNext()) { return true; } // If the next iterate will not move to the next sub bucket index (which is empty if // if we reached this point), then we are not yet done iterating (we want to iterate // until we are no longer on a value that has a count, rather than util we first reach // the last value that has a count. The difference is subtle but important)... return (histogram.lowestEquivalentValue((long) nextValueReportingLevel) < nextValueAtIndex); }
private void reset(final AbstractHistogram histogram, final long valueUnitsInFirstBucket, final double logBase) { super.resetIterator(histogram); this.logBase = logBase; this.valueUnitsInFirstBucket = valueUnitsInFirstBucket; nextValueReportingLevel = valueUnitsInFirstBucket; this.currentStepHighestValueReportingLevel = ((long) nextValueReportingLevel) - 1; this.currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
/** * Get a value that lies in the middle (rounded up) of the range of values equivalent the given value. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value The given value * @return The value lies in the middle (rounded up) of the range of values equivalent the given value. */ public long medianEquivalentValue(final long value) { return (lowestEquivalentValue(value) + (sizeOfEquivalentValueRange(value) >> 1)); }
/** * Get the next value that is not equivalent to the given value within the histogram's resolution. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value The given value * @return The next value that is not equivalent to the given value within the histogram's resolution. */ public long nextNonEquivalentValue(final long value) { return lowestEquivalentValue(value) + sizeOfEquivalentValueRange(value); }
private void reset(final AbstractHistogram histogram, final long valueUnitsPerBucket) { super.resetIterator(histogram); this.valueUnitsPerBucket = valueUnitsPerBucket; this.currentStepHighestValueReportingLevel = valueUnitsPerBucket - 1; this.currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
/** * Get the lowest value that is equivalent to the given value within the histogram's resolution. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value The given value * @return The lowest value that is equivalent to the given value within the histogram's resolution. */ public double lowestEquivalentValue(final double value) { return integerValuesHistogram.lowestEquivalentValue((long)(value * getDoubleToIntegerValueConversionRatio())) * getIntegerToDoubleValueConversionRatio(); }
long valueAtIndex = valueFromIndex(i); return (percentile == 0.0) ? lowestEquivalentValue(valueAtIndex) : highestEquivalentValue(valueAtIndex);
synchronized void fillBufferFromCountsArray(ByteBuffer buffer) { final int countsLimit = countsArrayIndex(maxValue) + 1; int srcIndex = 0; while (srcIndex < countsLimit) { // V2 encoding format uses a ZigZag LEB128-64b9B encoded long. Positive values are counts, // while negative values indicate a repeat zero counts. long count = getCountAtIndex(srcIndex++); if (count < 0) { throw new RuntimeException("Cannot encode histogram containing negative counts (" + count + ") at index " + srcIndex + ", corresponding the value range [" + lowestEquivalentValue(valueFromIndex(srcIndex)) + "," + nextNonEquivalentValue(valueFromIndex(srcIndex)) + ")"); } // Count trailing 0s (which follow this count): long zerosCount = 0; if (count == 0) { zerosCount = 1; while ((srcIndex < countsLimit) && (getCountAtIndex(srcIndex) == 0)) { zerosCount++; srcIndex++; } } if (zerosCount > 1) { ZigZagEncoding.putLong(buffer, -zerosCount); } else { ZigZagEncoding.putLong(buffer, count); } } }
@Override void incrementIterationLevel() { nextValueReportingLevel *= logBase; this.currentStepHighestValueReportingLevel = ((long)nextValueReportingLevel) - 1; currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
@Override void incrementIterationLevel() { currentStepHighestValueReportingLevel += valueUnitsPerBucket; currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
/** * Get a value that lies in the middle (rounded up) of the range of values equivalent the given value. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value The given value * @return The value lies in the middle (rounded up) of the range of values equivalent the given value. */ public long medianEquivalentValue(final long value) { return (lowestEquivalentValue(value) + (sizeOfEquivalentValueRange(value) >> 1)); }
@Override public boolean hasNext() { if (super.hasNext()) { return true; } // If the next iterate will not move to the next sub bucket index (which is empty if // if we reached this point), then we are not yet done iterating (we want to iterate // until we are no longer on a value that has a count, rather than util we first reach // the last value that has a count. The difference is subtle but important)... return (histogram.lowestEquivalentValue((long) nextValueReportingLevel) < nextValueAtIndex); }
private void reset(final AbstractHistogram histogram, final long valueUnitsInFirstBucket, final double logBase) { super.resetIterator(histogram); this.logBase = logBase; this.valueUnitsInFirstBucket = valueUnitsInFirstBucket; nextValueReportingLevel = valueUnitsInFirstBucket; this.currentStepHighestValueReportingLevel = ((long) nextValueReportingLevel) - 1; this.currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
/** * Get the next value that is not equivalent to the given value within the histogram's resolution. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value The given value * @return The next value that is not equivalent to the given value within the histogram's resolution. */ public long nextNonEquivalentValue(final long value) { return lowestEquivalentValue(value) + sizeOfEquivalentValueRange(value); }
private void reset(final AbstractHistogram histogram, final long valueUnitsPerBucket) { super.resetIterator(histogram); this.valueUnitsPerBucket = valueUnitsPerBucket; this.currentStepHighestValueReportingLevel = valueUnitsPerBucket - 1; this.currentStepLowestValueReportingLevel = histogram.lowestEquivalentValue(currentStepHighestValueReportingLevel); }
/** * Get the lowest value that is equivalent to the given value within the histogram's resolution. * Where "equivalent" means that value samples recorded for any two * equivalent values are counted in a common total count. * * @param value The given value * @return The lowest value that is equivalent to the given value within the histogram's resolution. */ public double lowestEquivalentValue(final double value) { return integerValuesHistogram.lowestEquivalentValue((long)(value * getDoubleToIntegerValueConversionRatio())) * getIntegerToDoubleValueConversionRatio(); }