public class TupleSketch extends KMVSketch
META_STD_DEV_1, META_STD_DEV_2, META_STD_DEV_3, META_STD_DEV_LB, META_STD_DEV_UB
Constructor and Description |
---|
TupleSketch(com.yahoo.sketches.ResizeFactor resizeFactor,
float samplingProbability,
int nominalEntries,
int maxSize,
com.yahoo.bullet.record.BulletRecordProvider provider)
Initialize a tuple sketch for summarizing group data.
|
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.
|
protected Double |
getLowerBound(int standardDeviation)
Gets the lower bound at this standard deviation after the last createResult.
|
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 Double |
getTheta()
Gets the theta value for this sketch after the last createResult.
|
protected Double |
getUpperBound(int standardDeviation)
Gets the uppper bound at this standard deviation after the last createResult.
|
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(String key,
CachingGroupData data)
Update the sketch with a key representing a group and the data for it.
|
merge, union, update
getMetadata
public TupleSketch(com.yahoo.sketches.ResizeFactor resizeFactor, float samplingProbability, int nominalEntries, int maxSize, com.yahoo.bullet.record.BulletRecordProvider provider)
resizeFactor
- The ResizeFactor
to use for the sketch.samplingProbability
- The sampling probability to use.nominalEntries
- The nominal entries for the sketch.maxSize
- The maximum size of groups to return.provider
- A BulletRecordProvider to generate BulletRecords.public void update(String key, CachingGroupData data)
key
- The key to present the data to the sketch as.data
- The data for the group.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 KMVSketch
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
protected Integer getSize()
Sketch
protected Double getTheta()
KMVSketch
DualSketch.merge()
.protected Double getLowerBound(int standardDeviation)
KMVSketch
DualSketch.merge()
.getLowerBound
in class KMVSketch
standardDeviation
- The standard deviation.protected Double getUpperBound(int standardDeviation)
KMVSketch
DualSketch.merge()
.getUpperBound
in class KMVSketch
standardDeviation
- The standard deviation.Copyright © 2021. All rights reserved.