@Override public IntCountsHistogram copy() { IntCountsHistogram copy = new IntCountsHistogram(this); copy.add(this); return copy; }
@Override public IntCountsHistogram copyCorrectedForCoordinatedOmission(final long expectedIntervalBetweenValueSamples) { IntCountsHistogram toHistogram = new IntCountsHistogram(this); toHistogram.addWhileCorrectingForCoordinatedOmission(this, expectedIntervalBetweenValueSamples); return toHistogram; }
/** * Construct a new histogram by decoding it from a ByteBuffer. * @param buffer The buffer to decode from * @param minBarForHighestTrackableValue Force highestTrackableValue to be set at least this high * @return The newly constructed histogram */ public static IntCountsHistogram decodeFromByteBuffer(final ByteBuffer buffer, final long minBarForHighestTrackableValue) { return (IntCountsHistogram) decodeFromByteBuffer(buffer, IntCountsHistogram.class, minBarForHighestTrackableValue); }
@Override void setCountAtIndex(int index, long value) { setCountAtNormalizedIndex(normalizeIndex(index, normalizingIndexOffset, countsArrayLength), value); }
@Override void resize(long newHighestTrackableValue) { int oldNormalizedZeroIndex = normalizeIndex(0, normalizingIndexOffset, countsArrayLength); establishSize(newHighestTrackableValue); int countsDelta = countsArrayLength - counts.length; counts = Arrays.copyOf(counts, countsArrayLength); if (oldNormalizedZeroIndex != 0) { // We need to shift the stuff from the zero index and up to the end of the array: int newNormalizedZeroIndex = oldNormalizedZeroIndex + countsDelta; int lengthToCopy = (countsArrayLength - countsDelta) - oldNormalizedZeroIndex; System.arraycopy(counts, oldNormalizedZeroIndex, counts, newNormalizedZeroIndex, lengthToCopy); Arrays.fill(counts, oldNormalizedZeroIndex, newNormalizedZeroIndex, 0); } }
} else _histogram = new IntCountsHistogram(LOW, HIGH, 3);
@Override long getCountAtIndex(final int index) { return counts[normalizeIndex(index, normalizingIndexOffset, countsArrayLength)]; }
@Override void shiftNormalizingIndexByOffset(int offsetToAdd, boolean lowestHalfBucketPopulated, double newIntegerToDoubleValueConversionRatio) { nonConcurrentNormalizingIndexShift(offsetToAdd, lowestHalfBucketPopulated); }
/** * Construct a new histogram by decoding it from a compressed form in a ByteBuffer. * @param buffer The buffer to decode from * @param minBarForHighestTrackableValue Force highestTrackableValue to be set at least this high * @return The newly constructed histogram * @throws DataFormatException on error parsing/decompressing the buffer */ public static IntCountsHistogram decodeFromCompressedByteBuffer(final ByteBuffer buffer, final long minBarForHighestTrackableValue) throws DataFormatException { return decodeFromCompressedByteBuffer(buffer, IntCountsHistogram.class, minBarForHighestTrackableValue); }
/** * Construct an auto-resizing IntCountsHistogram with a lowest discernible value of 1 and an auto-adjusting * highestTrackableValue. Can auto-resize up to track values up to (Long.MAX_VALUE / 2). * * @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant * decimal digits to which the histogram will maintain value resolution * and separation. Must be a non-negative integer between 0 and 5. */ public IntCountsHistogram(final int numberOfSignificantValueDigits) { this(1, 2, numberOfSignificantValueDigits); setAutoResize(true); }
@Override void setIntegerToDoubleValueConversionRatio(double integerToDoubleValueConversionRatio) { nonConcurrentSetIntegerToDoubleValueConversionRatio(integerToDoubleValueConversionRatio); }
@Override void setCountAtIndex(int index, long value) { setCountAtNormalizedIndex(normalizeIndex(index, normalizingIndexOffset, countsArrayLength), value); }
@Override void resize(long newHighestTrackableValue) { int oldNormalizedZeroIndex = normalizeIndex(0, normalizingIndexOffset, countsArrayLength); establishSize(newHighestTrackableValue); int countsDelta = countsArrayLength - counts.length; counts = Arrays.copyOf(counts, countsArrayLength); if (oldNormalizedZeroIndex != 0) { // We need to shift the stuff from the zero index and up to the end of the array: int newNormalizedZeroIndex = oldNormalizedZeroIndex + countsDelta; int lengthToCopy = (countsArrayLength - countsDelta) - oldNormalizedZeroIndex; System.arraycopy(counts, oldNormalizedZeroIndex, counts, newNormalizedZeroIndex, lengthToCopy); Arrays.fill(counts, oldNormalizedZeroIndex, newNormalizedZeroIndex, 0); } }
@Override void addToCountAtIndex(final int index, final long value) { int normalizedIndex = normalizeIndex(index, normalizingIndexOffset, countsArrayLength); long currentCount = counts[normalizedIndex]; long newCount = (currentCount + value); if ((newCount < Integer.MIN_VALUE) || (newCount > Integer.MAX_VALUE)) { throw new IllegalArgumentException("would overflow integer count"); } counts[normalizedIndex] = (int) newCount; }
@Override void shiftNormalizingIndexByOffset(int offsetToAdd, boolean lowestHalfBucketPopulated, double newIntegerToDoubleValueConversionRatio) { nonConcurrentNormalizingIndexShift(offsetToAdd, lowestHalfBucketPopulated); }
/** * Construct a new histogram by decoding it from a compressed form in a ByteBuffer. * @param buffer The buffer to decode from * @param minBarForHighestTrackableValue Force highestTrackableValue to be set at least this high * @return The newly constructed histogram * @throws DataFormatException on error parsing/decompressing the buffer */ public static IntCountsHistogram decodeFromCompressedByteBuffer(final ByteBuffer buffer, final long minBarForHighestTrackableValue) throws DataFormatException { return decodeFromCompressedByteBuffer(buffer, IntCountsHistogram.class, minBarForHighestTrackableValue); }
/** * Construct an auto-resizing IntCountsHistogram with a lowest discernible value of 1 and an auto-adjusting * highestTrackableValue. Can auto-resize up to track values up to (Long.MAX_VALUE / 2). * * @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant * decimal digits to which the histogram will maintain value resolution * and separation. Must be a non-negative integer between 0 and 5. */ public IntCountsHistogram(final int numberOfSignificantValueDigits) { this(1, 2, numberOfSignificantValueDigits); setAutoResize(true); }
@Override void setIntegerToDoubleValueConversionRatio(double integerToDoubleValueConversionRatio) { nonConcurrentSetIntegerToDoubleValueConversionRatio(integerToDoubleValueConversionRatio); }
@Override public IntCountsHistogram copy() { IntCountsHistogram copy = new IntCountsHistogram(this); copy.add(this); return copy; }
@Override public IntCountsHistogram copyCorrectedForCoordinatedOmission(final long expectedIntervalBetweenValueSamples) { IntCountsHistogram toHistogram = new IntCountsHistogram(this); toHistogram.addWhileCorrectingForCoordinatedOmission(this, expectedIntervalBetweenValueSamples); return toHistogram; }