public class SignedDDSketch extends java.lang.Object implements QuantileSketch<SignedDDSketch>
QuantileSketch with the same relative-error guarantees as DDSketch, but accepts
both negative and positive input values.
As the negative value store is reversed, to collapse the lowest values its supplier should
provide a CollapsingHighestDenseStore rather than a CollapsingLowestDenseStore.
| Constructor and Description |
|---|
SignedDDSketch(IndexMapping indexMapping,
java.util.function.Supplier<Store> storeSupplier)
Constructs an initially empty quantile sketch using the specified
IndexMapping and
Store supplier. |
SignedDDSketch(IndexMapping indexMapping,
java.util.function.Supplier<Store> negativeValueStoreSupplier,
java.util.function.Supplier<Store> positiveValueStoreSupplier)
Constructs an initially empty quantile sketch using the specified
IndexMapping and
Store suppliers. |
SignedDDSketch(IndexMapping indexMapping,
java.util.function.Supplier<Store> negativeValueStoreSupplier,
java.util.function.Supplier<Store> positiveValueStoreSupplier,
double minIndexedValue)
Constructs an initially empty quantile sketch using the specified
IndexMapping and Store
supplier. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(double value)
Adds a value to the sketch.
|
void |
accept(double value,
double count)
Adds a value to the sketch with a floating-point
count. |
void |
accept(double value,
long count)
Adds a value to the sketch as many times as specified by
count. |
SignedDDSketch |
copy() |
static SignedDDSketch |
fromProto(java.util.function.Supplier<? extends Store> storeSupplier,
com.datadoghq.sketch.ddsketch.proto.DDSketch proto)
Builds a new instance of
SignedDDSketch based on the provided protobuf representation. |
double |
getCount() |
IndexMapping |
getIndexMapping() |
double |
getMaxValue() |
double |
getMinValue() |
Store |
getNegativeValueStore() |
Store |
getPositiveValueStore() |
double |
getValueAtQuantile(double quantile) |
double[] |
getValuesAtQuantiles(double[] quantiles) |
boolean |
isEmpty() |
void |
mergeWith(SignedDDSketch other)
Merges the other sketch into this one.
|
com.datadoghq.sketch.ddsketch.proto.DDSketch |
toProto()
Generates a protobuf representation of this
SignedDDSketch. |
public SignedDDSketch(IndexMapping indexMapping, java.util.function.Supplier<Store> storeSupplier)
IndexMapping and
Store supplier.indexMapping - the mapping between floating-point values and integer indices to be used by the sketchstoreSupplier - the store constructor for keeping track of added valuespublic SignedDDSketch(IndexMapping indexMapping, java.util.function.Supplier<Store> negativeValueStoreSupplier, java.util.function.Supplier<Store> positiveValueStoreSupplier)
IndexMapping and
Store suppliers.indexMapping - the mapping between floating-point values and integer indices to be used by the sketchnegativeValueStoreSupplier - the store constructor for keeping track of added negative valuespositiveValueStoreSupplier - the store constructor for keeping track of added positive valuespublic SignedDDSketch(IndexMapping indexMapping, java.util.function.Supplier<Store> negativeValueStoreSupplier, java.util.function.Supplier<Store> positiveValueStoreSupplier, double minIndexedValue)
IndexMapping and Store
supplier.indexMapping - the mapping between floating-point values and integer indices to be used by the sketchnegativeValueStoreSupplier - the store constructor for keeping track of added negative valuespositiveValueStoreSupplier - the store constructor for keeping track of added positive valuesminIndexedValue - the least value that should be distinguished from zeropublic IndexMapping getIndexMapping()
public Store getNegativeValueStore()
public Store getPositiveValueStore()
public void accept(double value)
accept in interface QuantileSketch<SignedDDSketch>accept in interface java.util.function.DoubleConsumervalue - the value to be addedjava.lang.IllegalArgumentException - if the value is outside the range that is tracked by the sketchpublic void accept(double value,
long count)
count.accept in interface QuantileSketch<SignedDDSketch>value - the value to be addedcount - the number of times the value is to be addedjava.lang.IllegalArgumentException - if the value is outside the range that is tracked by the sketchpublic void accept(double value,
double count)
count.value - the value to be addedcount - the weight associated with the value to be addedjava.lang.IllegalArgumentException - if count is negativepublic void mergeWith(SignedDDSketch other)
mergeWith in interface QuantileSketch<SignedDDSketch>other - the sketch to be merged into this onejava.lang.IllegalArgumentException - if the other sketch does not use the same index mappingpublic SignedDDSketch copy()
copy in interface QuantileSketch<SignedDDSketch>public boolean isEmpty()
isEmpty in interface QuantileSketch<SignedDDSketch>public double getCount()
getCount in interface QuantileSketch<SignedDDSketch>public double getMinValue()
getMinValue in interface QuantileSketch<SignedDDSketch>public double getMaxValue()
getMaxValue in interface QuantileSketch<SignedDDSketch>public double getValueAtQuantile(double quantile)
getValueAtQuantile in interface QuantileSketch<SignedDDSketch>quantile - a number between 0 and 1 (both included)public double[] getValuesAtQuantiles(double[] quantiles)
getValuesAtQuantiles in interface QuantileSketch<SignedDDSketch>quantiles - number between 0 and 1 (both included)public com.datadoghq.sketch.ddsketch.proto.DDSketch toProto()
SignedDDSketch.SignedDDSketchpublic static SignedDDSketch fromProto(java.util.function.Supplier<? extends Store> storeSupplier, com.datadoghq.sketch.ddsketch.proto.DDSketch proto)
SignedDDSketch based on the provided protobuf representation.storeSupplier - the constructor of the Store implementation to be used for encoding bin countersproto - the protobuf representation of a sketchDDSketch that matches the protobuf representation