public class FrequentItemsSketch extends Sketch
ItemsSketch
of String.Modifier and Type | Field and Description |
---|---|
static String |
COUNT_FIELD |
static String |
ITEM_FIELD |
Constructor and Description |
---|
FrequentItemsSketch(com.yahoo.sketches.frequencies.ErrorType type,
int maxMapCapacity,
int maxSize,
com.yahoo.bullet.record.BulletRecordProvider provider)
Creates a FrequentItemsSketch with the given
ErrorType and the maximum map entries. |
FrequentItemsSketch(com.yahoo.sketches.frequencies.ErrorType type,
int maxMapCapacity,
long threshold,
int maxSize,
com.yahoo.bullet.record.BulletRecordProvider provider)
Creates a FrequentItemsSketch with the given
ErrorType , the maximum map entries, and threshold. |
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.
|
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. |
void |
update(String item)
Inserts an item into the Sketch.
|
getMetadata
public static final String ITEM_FIELD
public static final String COUNT_FIELD
public FrequentItemsSketch(com.yahoo.sketches.frequencies.ErrorType type, int maxMapCapacity, long threshold, int maxSize, com.yahoo.bullet.record.BulletRecordProvider provider)
ErrorType
, the maximum map entries, and threshold.type
- The ErrorType
for the Sketch.maxMapCapacity
- The maximum power of 2 entries for the Sketch used as the internal map size.threshold
- The threshold that will be used for selecting items if the Sketch error is less than it.maxSize
- The maximum size of the number of frequent items.provider
- A BulletRecordProvider to generate BulletRecords.public FrequentItemsSketch(com.yahoo.sketches.frequencies.ErrorType type, int maxMapCapacity, int maxSize, com.yahoo.bullet.record.BulletRecordProvider provider)
ErrorType
and the maximum map entries.type
- The ErrorType
for the Sketch.maxMapCapacity
- The maximum power of 2 entries for the Sketch used as the internal map size.maxSize
- The maximum size of the number of frequent items.provider
- A BulletRecordProvider to generate BulletRecords.public void update(String item)
item
- The String item to add to the Sketch.public void union(byte[] serialized)
Sketch
Sketch.serialize()
into this.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 byte[] serialize()
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.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.public void reset()
Sketch
Sketch.serialize()
or Sketch.getResult(String, Map)
if you want to add more data to the sketch.protected String getFamily()
Sketch
protected Boolean isEstimationMode()
Sketch
isEstimationMode
in class Sketch
Copyright © 2021. All rights reserved.