Class CompactSketch
public abstract class CompactSketch extends Sketch
A CompactSketch is the simplest form of a Theta Sketch. It consists of a compact list (i.e., no intervening spaces) of hash values, which may be ordered or not, a value for theta and a seed hash. A CompactSketch is read-only, and the space required when stored is only the space required for the hash values and 8 to 24 bytes of preamble. An empty CompactSketch consumes only 8 bytes.
- Author:
- Lee Rhodes
-
Constructor Summary
Constructors Constructor Description CompactSketch() -
Method Summary
Modifier and Type Method Description abstract CompactSketchcompact(boolean dstOrdered, org.apache.datasketches.memory.WritableMemory dstMem)Convert this sketch to a new CompactSketch of the chosen order and direct or on the heap.intgetCompactBytes()Returns the number of storage bytes required for this Sketch if its current state were compacted.FamilygetFamily()Returns the Family that this sketch belongs tobooleanisCompact()Returns true if this sketch is in compact form.Methods inherited from class org.apache.datasketches.theta.Sketch
compact, getCountLessThanThetaLong, getCurrentBytes, getEstimate, getLowerBound, getMaxCompactSketchBytes, getMaxUpdateSketchBytes, getRetainedEntries, getRetainedEntries, getSerializationVersion, getTheta, getThetaLong, getUpperBound, hasMemory, heapify, heapify, isDirect, isEmpty, isEstimationMode, isOrdered, isSameResource, iterator, toByteArray, toString, toString, toString, toString, wrap, wrap
-
Constructor Details
-
CompactSketch
public CompactSketch()
-
-
Method Details
-
compact
public abstract CompactSketch compact(boolean dstOrdered, org.apache.datasketches.memory.WritableMemory dstMem)Description copied from class:SketchConvert this sketch to a new CompactSketch of the chosen order and direct or on the heap.If this sketch is already in the proper form, this operation returns this, otherwise, this method returns a new CompactSketch of the proper form.
If this sketch is a type of UpdateSketch, the compacting process converts the hash table of the UpdateSketch to a simple list of the valid hash values. Any hash values of zero or equal-to or greater than theta will be discarded. The number of valid values remaining in the CompactSketch depends on a number of factors, but may be larger or smaller than Nominal Entries (or k). It will never exceed 2k. If it is critical to always limit the size to no more than k, then rebuild() should be called on the UpdateSketch prior to calling this method.
A CompactSketch is always immutable.
- Specified by:
compactin classSketch- Parameters:
dstOrdered- See Destination OrdereddstMem- See Destination Memory.- Returns:
- this sketch as a CompactSketch in the chosen form
-
getCompactBytes
public int getCompactBytes()Description copied from class:SketchReturns the number of storage bytes required for this Sketch if its current state were compacted. It this sketch is already in the compact form this is equivalent to callingSketch.getCurrentBytes().- Specified by:
getCompactBytesin classSketch- Returns:
- number of compact bytes
-
getFamily
Description copied from class:SketchReturns the Family that this sketch belongs to -
isCompact
public boolean isCompact()Description copied from class:SketchReturns true if this sketch is in compact form.
-