Class ArrayOfDoublesSketch
java.lang.Object
org.apache.datasketches.tuple.arrayofdoubles.ArrayOfDoublesSketch
- Direct Known Subclasses:
ArrayOfDoublesCompactSketch, ArrayOfDoublesUpdatableSketch
The base class for the tuple sketch of type ArrayOfDoubles, where an array of double values
is associated with each key.
A primitive array of doubles is used here, as opposed to a generic Summary object,
for improved performance.
-
Method Summary
Modifier and TypeMethodDescriptioncompact()Returns this sketch in compact form, which is immutable.abstract ArrayOfDoublesCompactSketchcompact(MemorySegment dstSeg) Returns this sketch in compact form, which is immutable.abstract intFor compact sketches this is the same as getMaxBytes().doubleEstimates the cardinality of the set (number of unique values presented to the sketch)doublegetLowerBound(int numStdDev) Gets the approximate lower error bound given the specified number of Standard Deviations.abstract intReturns the maximum number of bytes for this sketch when serialized.intReturns number of double values associated with each keyabstract intReturns number of retained entriesdoublegetTheta()Gets the value of theta as a double between zero and onedoublegetUpperBound(int numStdDev) Gets the approximate upper error bound given the specified number of Standard Deviations.abstract double[][]Returns array of arrays of double values in the sketchabstract booleanReturns true if this sketch's data structure is backed by MemorySegment.static ArrayOfDoublesSketchheapify(MemorySegment seg) Heapify the given MemorySegment as an ArrayOfDoublesSketchstatic ArrayOfDoublesSketchheapify(MemorySegment seg, long seed) Heapify the given MemorySegment and seed as a ArrayOfDoublesSketchstatic ArrayOfDoublesSketchheapifySketch(MemorySegment srcSeg) Heapify the given MemorySegment as an ArrayOfDoublesSketchstatic ArrayOfDoublesSketchheapifySketch(MemorySegment srcSeg, long seed) Heapify the given MemorySegment and seed as a ArrayOfDoublesSketchstatic ArrayOfDoublesUnionheapifyUnion(MemorySegment srcSeg) Heapify the given MemorySegment as an ArrayOfDoublesUnionstatic ArrayOfDoublesUnionheapifyUnion(MemorySegment srcSeg, long seed) Heapify the given MemorySegment and seed as an ArrayOfDoublesUnionheapifyUpdatableSketch(MemorySegment srcSeg) Heapify the given MemorySegment as an ArrayOfDoublesUpdatableSketchheapifyUpdatableSketch(MemorySegment srcSeg, long seed) Heapify the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketchbooleanisEmpty()booleanReturns true if the sketch is Estimation Mode (as opposed to Exact Mode).abstract ArrayOfDoublesSketchIteratoriterator()Returns an iterator over the sketchabstract byte[]Returns serialized representation of the sketchtoString()static ArrayOfDoublesSketchwrap(MemorySegment seg) Wrap the given MemorySegment as an ArrayOfDoublesSketch.static ArrayOfDoublesSketchwrap(MemorySegment seg, long seed) Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch.static ArrayOfDoublesSketchwrapSketch(MemorySegment srcSeg) Wrap the given MemorySegment as an ArrayOfDoublesSketch.static ArrayOfDoublesSketchwrapSketch(MemorySegment srcSeg, long seed) Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch.static ArrayOfDoublesUnionwrapUnion(MemorySegment srcSeg) Wrap the given MemorySegment as an ArrayOfDoublesUnion If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.static ArrayOfDoublesUnionwrapUnion(MemorySegment srcSeg, long seed) Wrap the given MemorySegment and seed as an ArrayOfDoublesUnion If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.wrapUpdatableSketch(MemorySegment srcSeg) Wrap the given MemorySegment as an ArrayOfDoublesUpdatableSketch.wrapUpdatableSketch(MemorySegment srcSeg, long seed) Wrap the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch.
-
Method Details
-
heapify
Heapify the given MemorySegment as an ArrayOfDoublesSketch- Parameters:
seg- the given MemorySegment- Returns:
- an ArrayOfDoublesSketch
-
heapify
Heapify the given MemorySegment and seed as a ArrayOfDoublesSketch- Parameters:
seg- the given MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesSketch
-
wrap
Wrap the given MemorySegment as an ArrayOfDoublesSketch. If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
seg- the given MemorySegment- Returns:
- an ArrayOfDoublesSketch
-
wrap
Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch. If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
seg- the given MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesSketch
-
getEstimate
public double getEstimate()Estimates the cardinality of the set (number of unique values presented to the sketch)- Returns:
- best estimate of the number of unique values
-
getUpperBound
public double getUpperBound(int numStdDev) Gets the approximate upper error bound given the specified number of Standard Deviations. This will return getEstimate() if isEmpty() is true.- Parameters:
numStdDev- See Number of Standard Deviations- Returns:
- the upper bound.
-
getLowerBound
public double getLowerBound(int numStdDev) Gets the approximate lower error bound given the specified number of Standard Deviations. This will return getEstimate() if isEmpty() is true.- Parameters:
numStdDev- See Number of Standard Deviations- Returns:
- the lower bound.
-
hasMemorySegment
public abstract boolean hasMemorySegment()Returns true if this sketch's data structure is backed by MemorySegment.- Returns:
- true if this sketch's data structure is backed by MemorySegment.
-
isEmpty
-
getNumValues
public int getNumValues()Returns number of double values associated with each key- Returns:
- number of double values associated with each key
-
isEstimationMode
public boolean isEstimationMode()Returns true if the sketch is Estimation Mode (as opposed to Exact Mode). This is true if theta < 1.0 AND isEmpty() is false.- Returns:
- true if the sketch is in estimation mode.
-
getTheta
public double getTheta()Gets the value of theta as a double between zero and one- Returns:
- the value of theta as a double
-
getRetainedEntries
public abstract int getRetainedEntries()Returns number of retained entries- Returns:
- number of retained entries
-
getMaxBytes
public abstract int getMaxBytes()Returns the maximum number of bytes for this sketch when serialized.- Returns:
- the maximum number of bytes for this sketch when serialized.
-
getCurrentBytes
public abstract int getCurrentBytes()For compact sketches this is the same as getMaxBytes().- Returns:
- the current number of bytes for this sketch when serialized.
-
toByteArray
public abstract byte[] toByteArray()Returns serialized representation of the sketch- Returns:
- serialized representation of the sketch
-
getValues
public abstract double[][] getValues()Returns array of arrays of double values in the sketch- Returns:
- array of arrays of double values in the sketch
-
iterator
Returns an iterator over the sketch- Returns:
- an iterator over the sketch
-
compact
Returns this sketch in compact form, which is immutable.- Returns:
- this sketch in compact form, which is immutable.
-
compact
Returns this sketch in compact form, which is immutable.- Parameters:
dstSeg- the destination MemorySegment- Returns:
- this sketch in compact form, which is immutable.
-
toString
-
wrapUnion
Wrap the given MemorySegment and seed as an ArrayOfDoublesUnion If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
srcSeg- the given source MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesUnion
-
wrapUnion
Wrap the given MemorySegment as an ArrayOfDoublesUnion If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
srcSeg- the given source MemorySegment- Returns:
- an ArrayOfDoublesUnion
-
heapifyUnion
Heapify the given MemorySegment and seed as an ArrayOfDoublesUnion- Parameters:
srcSeg- the given source MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesUnion
-
heapifyUnion
Heapify the given MemorySegment as an ArrayOfDoublesUnion- Parameters:
srcSeg- the given source MemorySegment- Returns:
- an ArrayOfDoublesUnion
-
wrapUpdatableSketch
Wrap the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch. If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
srcSeg- the given source MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesUpdatableSketch
-
wrapUpdatableSketch
Wrap the given MemorySegment as an ArrayOfDoublesUpdatableSketch. If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
srcSeg- the given source MemorySegment- Returns:
- an ArrayOfDoublesUpdatableSketch
-
wrapSketch
Wrap the given MemorySegment and seed as a ArrayOfDoublesSketch. If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
srcSeg- the given source MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesSketch
-
wrapSketch
Wrap the given MemorySegment as an ArrayOfDoublesSketch. If the given source MemorySegment is read-only, the returned TupleUnion object will also be read-only.- Parameters:
srcSeg- the given source MemorySegment- Returns:
- an ArrayOfDoublesSketch
-
heapifyUpdatableSketch
Heapify the given MemorySegment and seed as a ArrayOfDoublesUpdatableSketch- Parameters:
srcSeg- the given source MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesUpdatableSketch
-
heapifyUpdatableSketch
Heapify the given MemorySegment as an ArrayOfDoublesUpdatableSketch- Parameters:
srcSeg- the given source MemorySegment- Returns:
- an ArrayOfDoublesUpdatableSketch
-
heapifySketch
Heapify the given MemorySegment and seed as a ArrayOfDoublesSketch- Parameters:
srcSeg- the given source MemorySegmentseed- the given seed- Returns:
- an ArrayOfDoublesSketch
-
heapifySketch
Heapify the given MemorySegment as an ArrayOfDoublesSketch- Parameters:
srcSeg- the given source MemorySegment- Returns:
- an ArrayOfDoublesSketch
-