public class ApproximateHistogram extends Object
Modifier and Type | Field and Description |
---|---|
long[] |
bins |
static int |
DEFAULT_BUCKET_SIZE |
static int |
DEFAULT_HISTOGRAM_SIZE |
float[] |
positions |
Constructor and Description |
---|
ApproximateHistogram() |
ApproximateHistogram(int size) |
ApproximateHistogram(int binCount,
float[] positions,
long[] bins,
float min,
float max) |
ApproximateHistogram(int size,
float[] positions,
long[] bins,
int binCount,
float min,
float max,
long count,
float lowerLimit,
float upperLimit) |
ApproximateHistogram(int size,
float lowerLimit,
float upperLimit) |
Modifier and Type | Method and Description |
---|---|
int |
binCount() |
long[] |
bins() |
boolean |
canStoreCompact()
Checks whether this approximate histogram can be stored in a compact form
|
int |
capacity() |
ApproximateHistogram |
copy(ApproximateHistogram h)
Copies histogram h into the current histogram.
|
long |
count() |
boolean |
equals(Object o) |
ApproximateHistogram |
fold(ApproximateHistogram h) |
ApproximateHistogram |
fold(ApproximateHistogram h,
float[] mergedPositions,
long[] mergedBins,
float[] deltas) |
ApproximateHistogram |
foldFast(ApproximateHistogram h) |
ApproximateHistogram |
foldFast(ApproximateHistogram h,
float[] mergedPositions,
long[] mergedBins) |
protected ApproximateHistogram |
foldMin(ApproximateHistogram h,
float[] mergedPositions,
long[] mergedBins,
float[] deltas) |
protected ApproximateHistogram |
foldRule(ApproximateHistogram h,
float[] mergedPositions,
long[] mergedBins) |
static ApproximateHistogram |
fromBytes(byte[] bytes)
Constructs an Approximate Histogram object from the given byte-array representation
|
static ApproximateHistogram |
fromBytes(ByteBuffer buf)
Constructs an ApproximateHistogram object from the given byte-buffer representation
|
static ApproximateHistogram |
fromBytesCompact(ByteBuffer buf)
Constructs an ApproximateHistogram object from the given compact byte-buffer representation
|
static ApproximateHistogram |
fromBytesDense(ByteBuffer buf)
Constructs an ApproximateHistogram object from the given dense byte-buffer representation
|
static ApproximateHistogram |
fromBytesSparse(ByteBuffer buf)
Constructs an ApproximateHistogram object from the given dense byte-buffer representation
|
protected String |
getBinsString() |
int |
getCompactStorageSize() |
int |
getDenseStorageSize() |
long |
getExactCount() |
float |
getMax() |
int |
getMaxStorageSize() |
float |
getMin() |
int |
getMinStorageSize()
Returns the minimum number of bytes required to store this ApproximateHistogram object
|
float[] |
getQuantiles(float[] probabilities)
Returns the approximate quantiles corresponding to the given probabilities.
|
int |
getSparseStorageSize() |
int |
hashCode() |
float |
max() |
protected void |
merge(int index)
Merges the bin in the given position with the next bin
|
protected void |
mergeInsert(int mergeAt,
int insertAt,
float v,
long c)
Merges the bin in the mergeAt position with the bin in position mergeAt+1
and simultaneously inserts the given bin (v,c) as a new bin at position insertAt
|
float |
min() |
protected int |
minDeltaIndex() |
void |
offer(float value)
Adds the given value to the histogram
|
float[] |
positions() |
protected int |
ruleCombineBins(int leftBinCount,
float[] leftPositions,
long[] leftBins,
int rightBinCount,
float[] rightPositions,
long[] rightBins,
float[] mergedPositions,
long[] mergedBins) |
void |
setLowerLimit(float lowerLimit) |
void |
setUpperLimit(float upperLimit) |
protected void |
shiftLeft(int start,
int end)
Shifts the given range of histogram bins one slot to the left
|
protected void |
shiftRight(int start,
int end)
Shifts the given range the histogram bins one slot to the right
|
double |
sum(float b)
Returns the approximate number of items less than or equal to b in the histogram
|
byte[] |
toBytes()
Returns a byte-array representation of this ApproximateHistogram object
|
void |
toBytes(ByteBuffer buf)
Writes the representation of this ApproximateHistogram object to the given byte-buffer
|
void |
toBytesCompact(ByteBuffer buf)
Returns a compact byte-buffer representation of this ApproximateHistogram object
storing actual values as opposed to histogram bins
Requires 3 + 4 * count bytes of storage with count <= 127
|
void |
toBytesDense(ByteBuffer buf)
Writes the dense representation of this ApproximateHistogram object to the given byte-buffer
Requires 16 + 12 * size bytes of storage
|
void |
toBytesSparse(ByteBuffer buf)
Writes the sparse representation of this ApproximateHistogram object to the given byte-buffer
Requires 16 + 12 * binCount bytes of storage
|
Histogram |
toHistogram(float[] breaks)
Computes a visual representation of the approximate histogram with bins laid out according to the given breaks
|
Histogram |
toHistogram(float bucketSize,
float offset)
Computes a visual representation given an initial breakpoint, offset, and a bucket size.
|
Histogram |
toHistogram(int size)
Computes a visual representation of the approximate histogram with a given number of equal-sized bins
|
String |
toString() |
public static final int DEFAULT_HISTOGRAM_SIZE
public static final int DEFAULT_BUCKET_SIZE
public float[] positions
public long[] bins
public ApproximateHistogram(int size, float[] positions, long[] bins, int binCount, float min, float max, long count, float lowerLimit, float upperLimit)
public ApproximateHistogram()
public ApproximateHistogram(int size)
public ApproximateHistogram(int size, float lowerLimit, float upperLimit)
public ApproximateHistogram(int binCount, float[] positions, long[] bins, float min, float max)
public long count()
public float min()
public float max()
public int binCount()
public int capacity()
public float[] positions()
public long[] bins()
public long getExactCount()
public float getMin()
public float getMax()
protected String getBinsString()
public void setLowerLimit(float lowerLimit)
public void setUpperLimit(float upperLimit)
public void offer(float value)
value
- the value to be addedprotected int minDeltaIndex()
protected void merge(int index)
index
- index of the bin to merge, index must satisfy 0 <= index < binCount - 1protected void mergeInsert(int mergeAt, int insertAt, float v, long c)
mergeAt
- index of the bin to be mergedinsertAt
- index to insert the new bin atv
- bin positionc
- bin countprotected void shiftRight(int start, int end)
start
- index of the first bin to shiftend
- index of the rightmost bin to shift intoprotected void shiftLeft(int start, int end)
start
- index of the leftmost empty bin to shift intoend
- index of the last bin to shift leftpublic ApproximateHistogram fold(ApproximateHistogram h)
public ApproximateHistogram fold(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins, float[] deltas)
public ApproximateHistogram foldFast(ApproximateHistogram h)
public ApproximateHistogram foldFast(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins)
h
- histogram to be merged into the current histogrammergedPositions
- temporary buffer of size greater or equal to this.capacity()mergedBins
- temporary buffer of size greater or equal to this.capacity()public ApproximateHistogram copy(ApproximateHistogram h)
h
- ApproximateHistogram to copyprotected ApproximateHistogram foldMin(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins, float[] deltas)
protected ApproximateHistogram foldRule(ApproximateHistogram h, float[] mergedPositions, long[] mergedBins)
protected int ruleCombineBins(int leftBinCount, float[] leftPositions, long[] leftBins, int rightBinCount, float[] rightPositions, long[] rightBins, float[] mergedPositions, long[] mergedBins)
public byte[] toBytes()
public int getDenseStorageSize()
public int getSparseStorageSize()
public int getCompactStorageSize()
public int getMaxStorageSize()
public int getMinStorageSize()
public boolean canStoreCompact()
public void toBytes(ByteBuffer buf)
buf
- ByteBuffer to write the ApproximateHistogram topublic void toBytesDense(ByteBuffer buf)
buf
- ByteBuffer to write the ApproximateHistogram topublic void toBytesSparse(ByteBuffer buf)
buf
- ByteBuffer to write the ApproximateHistogram topublic void toBytesCompact(ByteBuffer buf)
buf
- ByteBuffer to write the ApproximateHistogram topublic static ApproximateHistogram fromBytes(byte[] bytes)
bytes
- byte array to construct an ApproximateHistogram frompublic static ApproximateHistogram fromBytesDense(ByteBuffer buf)
buf
- ByteBuffer to construct an ApproximateHistogram frompublic static ApproximateHistogram fromBytesSparse(ByteBuffer buf)
buf
- ByteBuffer to construct an ApproximateHistogram frompublic static ApproximateHistogram fromBytesCompact(ByteBuffer buf)
buf
- ByteBuffer to construct an ApproximateHistogram frompublic static ApproximateHistogram fromBytes(ByteBuffer buf)
buf
- ByteBuffer to construct an ApproximateHistogram frompublic double sum(float b)
b
- the cutoffpublic float[] getQuantiles(float[] probabilities)
probabilities
- array of probabilitiespublic Histogram toHistogram(float[] breaks)
breaks
- breaks defining the histogram binspublic Histogram toHistogram(int size)
size
- number of equal-sized bins to divide the histogram intopublic Histogram toHistogram(float bucketSize, float offset)
bucketSize
- the size of each bucketoffset
- the location of one breakpointCopyright © 2011–2015. All rights reserved.