Package org.apache.datasketches.tuple
Class CompactSketch<S extends Summary>
- java.lang.Object
-
- org.apache.datasketches.tuple.Sketch<S>
-
- org.apache.datasketches.tuple.CompactSketch<S>
-
- Type Parameters:
S
- type of Summary
public final class CompactSketch<S extends Summary> extends Sketch<S>
CompactSketches are never created directly. They are created as a result of the compact() method of an UpdatableSketch or as a result of the getResult() method of a set operation like Union, Intersection or AnotB. CompactSketch consists of a compact list (i.e. no intervening spaces) of hash values, corresponding list of Summaries, and a value for theta. The lists may or may not be ordered. CompactSketch is read-only.
-
-
Field Summary
-
Fields inherited from class org.apache.datasketches.tuple.Sketch
PREAMBLE_LONGS, summaryFactory_
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompactSketch<S>
compact()
Converts this sketch to a CompactSketch on the Java heap.int
getCountLessThanThetaLong(long thetaLong)
Gets the number of hash values less than the given theta expressed as a long.int
getRetainedEntries()
TupleSketchIterator<S>
iterator()
Returns a SketchIteratorbyte[]
toByteArray()
This is to serialize a sketch instance to a byte array.-
Methods inherited from class org.apache.datasketches.tuple.Sketch
getEstimate, getEstimate, getLowerBound, getLowerBound, getSummaryFactory, getTheta, getThetaLong, getUpperBound, getUpperBound, isEmpty, isEstimationMode, toString
-
-
-
-
Method Detail
-
compact
public CompactSketch<S> compact()
Description copied from class:Sketch
Converts this sketch to a CompactSketch on the Java heap.If this sketch is already in compact form this operation returns this.
-
getRetainedEntries
public int getRetainedEntries()
- Specified by:
getRetainedEntries
in classSketch<S extends Summary>
- Returns:
- number of retained entries
-
getCountLessThanThetaLong
public int getCountLessThanThetaLong(long thetaLong)
Description copied from class:Sketch
Gets the number of hash values less than the given theta expressed as a long.- Specified by:
getCountLessThanThetaLong
in classSketch<S extends Summary>
- Parameters:
thetaLong
- the given theta as a long between zero and Long.MAX_VALUE.- Returns:
- the number of hash values less than the given thetaLong.
-
toByteArray
public byte[] toByteArray()
Description copied from class:Sketch
This is to serialize a sketch instance to a byte array.As of 3.0.0, serializing an UpdatableSketch is deprecated. This capability will be removed in a future release. Serializing a CompactSketch is not deprecated.
- Specified by:
toByteArray
in classSketch<S extends Summary>
- Returns:
- serialized representation of the sketch
-
-