public class QuantileSketch extends DualSketch
DoublesSketch
- Quantile Sketch.Modifier and Type | Field and Description |
---|---|
static String |
COUNT_FIELD |
static String |
END_EXCLUSIVE |
static String |
INFINITY |
static String |
NEGATIVE_INFINITY |
static String |
NEGATIVE_INFINITY_START |
static String |
POSITIVE_INFINITY |
static String |
POSITIVE_INFINITY_END |
static String |
PROBABILITY_FIELD |
static String |
QUANTILE_FIELD |
static double |
QUANTILE_MAX |
static double |
QUANTILE_MIN |
static String |
RANGE_FIELD |
static String |
SEPARATOR |
static String |
START_EXCLUSIVE |
static String |
START_INCLUSIVE |
static String |
VALUE_FIELD |
Constructor and Description |
---|
QuantileSketch(int k,
DistributionType type,
double[] points,
com.yahoo.bullet.record.BulletRecordProvider provider)
Creates a quantile sketch with the given number of entries getting results with the given points.
|
QuantileSketch(int k,
int rounding,
DistributionType type,
int numberOfPoints,
com.yahoo.bullet.record.BulletRecordProvider provider)
Creates a quantile sketch with the given number of entries generating results with the number of
points (evenly-spaced).
|
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
addMetadata(Map<String,String> conceptKeys)
Adds the common metadata for this Sketch to
Map . |
protected String |
getFamily()
Returns a String representing the family of this sketch.
|
List<com.yahoo.bullet.record.BulletRecord> |
getRecords()
Collects the data presented to the sketch so far and returns the
List of BulletRecord
representation of the resulting data in the sketch. |
Clip |
getResult(String metaKey,
Map<String,String> conceptKeys)
Gets the result from the data presented to the sketch as a
Clip . |
protected Integer |
getSize()
Returns the size of the Sketch in bytes.
|
protected Boolean |
isEstimationMode()
Returns whether this sketch was in estimation mode or not.
|
protected void |
mergeBothSketches()
Merge and reset both the update sketch and the union sketch into the result.
|
protected void |
mergeUnionSketch()
Merge and reset just the union sketch into the result.
|
protected void |
mergeUpdateSketch()
Merge and reset just the update sketch into the result.
|
void |
reset()
Resets the Sketch to the original state.
|
byte[] |
serialize()
Serializes the sketch.
|
void |
union(byte[] serialized)
Union a sketch serialized using
Sketch.serialize() into this. |
protected boolean |
unionedExistingResults()
Merge the existing result into the union sketch if needed and return a boolean if the union was done.
|
void |
update(double data)
Updates the sketch with a double.
|
merge, union, update
getMetadata
public static final double QUANTILE_MIN
public static final double QUANTILE_MAX
public static final String QUANTILE_FIELD
public static final String VALUE_FIELD
public static final String PROBABILITY_FIELD
public static final String COUNT_FIELD
public static final String RANGE_FIELD
public static final String START_INCLUSIVE
public static final String START_EXCLUSIVE
public static final String END_EXCLUSIVE
public static final String SEPARATOR
public static final String INFINITY
public static final String POSITIVE_INFINITY
public static final String NEGATIVE_INFINITY
public static final String NEGATIVE_INFINITY_START
public static final String POSITIVE_INFINITY_END
public QuantileSketch(int k, DistributionType type, double[] points, com.yahoo.bullet.record.BulletRecordProvider provider)
k
- A number representative of the size of the sketch.type
- A DistributionType
that determines what the points mean.points
- An array of points to get the quantiles, PMF and/or CDF for.provider
- A BulletRecordProvider to generate BulletRecords.public QuantileSketch(int k, int rounding, DistributionType type, int numberOfPoints, com.yahoo.bullet.record.BulletRecordProvider provider)
k
- A number representative of the size of the sketch.rounding
- A number representing how many max decimal places points should have.type
- A DistributionType
that determines what the points mean.numberOfPoints
- A positive number of evenly spaced points in the range for the type to get the data for.provider
- A BulletRecordProvider to generate BulletRecords.public void update(double data)
data
- A double to insert into the sketch.public void union(byte[] serialized)
Sketch
Sketch.serialize()
into this.public byte[] serialize()
Sketch
public List<com.yahoo.bullet.record.BulletRecord> getRecords()
Sketch
List
of BulletRecord
representation of the resulting data in the sketch. See Sketch.getResult(String, Map)
for getting the
result including the metadata and see Sketch.getMetadata(String, Map)
for getting only the metadata.getRecords
in class Sketch
public Clip getResult(String metaKey, Map<String,String> conceptKeys)
Sketch
getResult
in class Sketch
metaKey
- If set to a non-null value, Sketch metadata will be added to the result.conceptKeys
- If provided, these Meta.Concept
names will be added to the metadata.Clip
of the results.public void reset()
DualSketch
Sketch.serialize()
or Sketch.getResult(String, Map)
if you want to add more data to the sketch.
Call this after your reset operations to reset the metadata relating to storing two sketches. You should
reset or remove all your sketches here.reset
in class DualSketch
protected void mergeBothSketches()
DualSketch
mergeBothSketches
in class DualSketch
protected void mergeUpdateSketch()
DualSketch
mergeUpdateSketch
in class DualSketch
protected void mergeUnionSketch()
DualSketch
mergeUnionSketch
in class DualSketch
protected boolean unionedExistingResults()
DualSketch
unionedExistingResults
in class DualSketch
protected Map<String,Object> addMetadata(Map<String,String> conceptKeys)
Sketch
Map
.addMetadata
in class Sketch
conceptKeys
- The Map
of Meta.Concept
names to their keys.Map
of sketch metadata.protected Boolean isEstimationMode()
Sketch
isEstimationMode
in class Sketch
protected String getFamily()
Sketch
Copyright © 2021. All rights reserved.