Class NormalSketch
java.lang.Object
com.yahoo.vespa.objects.Selectable
com.yahoo.vespa.objects.Identifiable
com.yahoo.searchlib.aggregation.hll.Sketch<NormalSketch>
com.yahoo.searchlib.aggregation.hll.NormalSketch
- All Implemented Interfaces:
Cloneable
Sketch used by the HyperLogLog (HLL) algorithm.
- Author:
- bjorncs
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a sketch with the default precision given byHyperLogLog.DEFAULT_PRECISION.NormalSketch(int precision) Create a sketch with a given HLL precision parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoidaggregate(int hash) Aggregates the hash value.voidAggregates the hash values.byte[]data()Returns the underlying byte array backing the sketch.booleaninthashCode()voidmerge(NormalSketch other) Lossless merge of sketches.protected voidonDeserialize(com.yahoo.vespa.objects.Deserializer buf) protected intprotected voidonSerialize(com.yahoo.vespa.objects.Serializer buf) Serializes the Sketch.intsize()Sketch size.toString()Methods inherited from class com.yahoo.vespa.objects.Identifiable
clone, create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getRawUtf8Bytes, getUtf8, putUtf8, registerClass, serialize, serializeOptional, serializeWithId, visitMembersMethods inherited from class com.yahoo.vespa.objects.Selectable
select, select, selectMembers
-
Field Details
-
classId
public static final int classId
-
-
Constructor Details
-
NormalSketch
public NormalSketch()Create a sketch with the default precision given byHyperLogLog.DEFAULT_PRECISION. -
NormalSketch
public NormalSketch(int precision) Create a sketch with a given HLL precision parameter.- Parameters:
precision- The precision parameter used by HLL. Determines the size of the sketch.
-
-
Method Details
-
merge
Lossless merge of sketches. Performs a pairwise maximum on the underlying data array.- Specified by:
mergein classSketch<NormalSketch>- Parameters:
other- Other sketch
-
aggregate
Aggregates the hash values.- Specified by:
aggregatein classSketch<NormalSketch>- Parameters:
hashValues- Provides an iterator for the hash values
-
aggregate
public void aggregate(int hash) Aggregates the hash value.- Specified by:
aggregatein classSketch<NormalSketch>- Parameters:
hash- Hash value.
-
onSerialize
protected void onSerialize(com.yahoo.vespa.objects.Serializer buf) Serializes the Sketch. Serialization format ================== Original size: 4 bytes Compressed size: 4 bytes Compressed data: N * 1 bytes Invariant: compressed size <= original size Special case: compressed size == original size => data is uncompressed- Overrides:
onSerializein classcom.yahoo.vespa.objects.Identifiable- Parameters:
buf- Serializer
-
onDeserialize
protected void onDeserialize(com.yahoo.vespa.objects.Deserializer buf) - Overrides:
onDeserializein classcom.yahoo.vespa.objects.Identifiable
-
data
public byte[] data()Returns the underlying byte array backing the sketch.- Returns:
- The underlying sketch data
-
size
public int size()Sketch size.- Returns:
- Number of buckets in the sketch.
-
equals
- Overrides:
equalsin classcom.yahoo.vespa.objects.Identifiable
-
hashCode
public int hashCode()- Overrides:
hashCodein classcom.yahoo.vespa.objects.Identifiable
-
onGetClassId
protected int onGetClassId()- Overrides:
onGetClassIdin classcom.yahoo.vespa.objects.Identifiable
-
toString
- Overrides:
toStringin classcom.yahoo.vespa.objects.Identifiable
-