Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Written by Gil Tene of Azul Systems, and released to the public domain, as explained at

Gil Tene
 package org.HdrHistogram;
A base class for all encodable (and decodable) histogram classes. Log readers and writers will generally use this base class to provide common log processing across the integer value based AbstractHistogram subclasses and the double value based DoubleHistogram class.
public abstract class EncodableHistogram {
    public abstract int getNeededByteBufferCapacity();
    public abstract int encodeIntoCompressedByteBuffer(final ByteBuffer targetBufferint compressionLevel);
    public abstract long getStartTimeStamp();
    public abstract void setStartTimeStamp(long startTimeStamp);
    public abstract long getEndTimeStamp();
    public abstract void setEndTimeStamp(long endTimestamp);
    public abstract double getMaxValueAsDouble();

Decode a from a compressed byte buffer. Will return either a Histogram or DoubleHistogram depending on the format found in the supplied buffer.

buffer The input buffer to decode from.
minBarForHighestTrackableValue A lower bound either on the highestTrackableValue of the created Histogram, or on the HighestToLowestValueRatio of the created DoubleHistogram.
The decoded Histogram or DoubleHistogram
Throws: on errors in decoding the buffer compression.
            ByteBuffer buffer,
            final long minBarForHighestTrackableValuethrows DataFormatException {
        // Peek iun buffer to see the cookie:
        int cookie = buffer.getInt(buffer.position());
        if (DoubleHistogram.isDoubleHistogramCookie(cookie)) {
            return DoubleHistogram.decodeFromCompressedByteBuffer(bufferminBarForHighestTrackableValue);
        } else {
            return Histogram.decodeFromCompressedByteBuffer(bufferminBarForHighestTrackableValue);
New to GrepCode? Check out our FAQ X