@Override public ShortCountsHistogram copyCorrectedForCoordinatedOmission(final long expectedIntervalBetweenValueSamples) { ShortCountsHistogram toHistogram = new ShortCountsHistogram(this); toHistogram.addWhileCorrectingForCoordinatedOmission(this, expectedIntervalBetweenValueSamples); return toHistogram; }
@Override public ShortCountsHistogram copy() { ShortCountsHistogram copy = new ShortCountsHistogram(this); copy.add(this); return copy; }
/** * 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 ShortCountsHistogram decodeFromByteBuffer(final ByteBuffer buffer, final long minBarForHighestTrackableValue) { return (ShortCountsHistogram) decodeFromByteBuffer(buffer, ShortCountsHistogram.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, (short) 0); } }
if (historyLength <= Short.MAX_VALUE) _histogram = new ShortCountsHistogram(LOW, HIGH, 3); } else
@Override long getCountAtIndex(final int index) { return counts[normalizeIndex(index, normalizingIndexOffset, countsArrayLength)]; }
/** * Construct an auto-resizing ShortCountsHistogram 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 ShortCountsHistogram(final int numberOfSignificantValueDigits) { this(1, 2, numberOfSignificantValueDigits); setAutoResize(true); }
/** * 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 ShortCountsHistogram decodeFromCompressedByteBuffer(final ByteBuffer buffer, final long minBarForHighestTrackableValue) throws DataFormatException { return decodeFromCompressedByteBuffer(buffer, ShortCountsHistogram.class, minBarForHighestTrackableValue); }
@Override void shiftNormalizingIndexByOffset(int offsetToAdd, boolean lowestHalfBucketPopulated, double newIntegerToDoubleValueConversionRatio) { nonConcurrentNormalizingIndexShift(offsetToAdd, lowestHalfBucketPopulated); }
@Override void setIntegerToDoubleValueConversionRatio(double integerToDoubleValueConversionRatio) { nonConcurrentSetIntegerToDoubleValueConversionRatio(integerToDoubleValueConversionRatio); }
@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, (short) 0); } }
@Override void setCountAtIndex(int index, long value) { setCountAtNormalizedIndex(normalizeIndex(index, normalizingIndexOffset, countsArrayLength), value); }
@Override void incrementCountAtIndex(final int index) { int normalizedIndex = normalizeIndex(index, normalizingIndexOffset, countsArrayLength); short currentCount = counts[normalizedIndex]; short newCount = (short) (currentCount + 1); if (newCount < 0) { throw new IllegalStateException("would overflow short integer count"); } counts[normalizedIndex] = newCount; }
/** * Construct an auto-resizing ShortCountsHistogram 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 ShortCountsHistogram(final int numberOfSignificantValueDigits) { this(1, 2, numberOfSignificantValueDigits); setAutoResize(true); }
/** * 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 ShortCountsHistogram decodeFromCompressedByteBuffer(final ByteBuffer buffer, final long minBarForHighestTrackableValue) throws DataFormatException { return decodeFromCompressedByteBuffer(buffer, ShortCountsHistogram.class, minBarForHighestTrackableValue); }
@Override void shiftNormalizingIndexByOffset(int offsetToAdd, boolean lowestHalfBucketPopulated, double newIntegerToDoubleValueConversionRatio) { nonConcurrentNormalizingIndexShift(offsetToAdd, lowestHalfBucketPopulated); }
@Override void setIntegerToDoubleValueConversionRatio(double integerToDoubleValueConversionRatio) { nonConcurrentSetIntegerToDoubleValueConversionRatio(integerToDoubleValueConversionRatio); }
@Override public ShortCountsHistogram copyCorrectedForCoordinatedOmission(final long expectedIntervalBetweenValueSamples) { ShortCountsHistogram toHistogram = new ShortCountsHistogram(this); toHistogram.addWhileCorrectingForCoordinatedOmission(this, expectedIntervalBetweenValueSamples); return toHistogram; }
@Override public ShortCountsHistogram copy() { ShortCountsHistogram copy = new ShortCountsHistogram(this); copy.add(this); return copy; }