Package org.apache.datasketches.theta
Class Sketches
java.lang.Object
org.apache.datasketches.theta.Sketches
This class brings together the common sketch and set operation creation methods and
the public static methods into one place.
- Author:
- Lee Rhodes
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgetCompactSketchMaxBytes(int lgNomEntries) Returns the maximum number of storage bytes required for a CompactSketch given the configured log_base2 of the number of nominal entries, which is a power of 2.static doublegetEstimate(org.apache.datasketches.memory.Memory srcMem) Gets the unique count estimate from a valid memory image of a Sketchstatic doublegetLowerBound(int numStdDev, org.apache.datasketches.memory.Memory srcMem) Gets the approximate lower error bound from a valid memory image of a Sketch given the specified number of Standard Deviations.static intgetMaxAnotBResultBytes(int maxNomEntries) static intgetMaxCompactSketchBytes(int numberOfEntries) Returns the maximum number of storage bytes required for a CompactSketch with the given number of actual entries.static intgetMaxIntersectionBytes(int nomEntries) static intgetMaxUnionBytes(int nomEntries) static intgetMaxUpdateSketchBytes(int nomEntries) static intgetSerializationVersion(org.apache.datasketches.memory.Memory srcMem) static doublegetUpperBound(int numStdDev, org.apache.datasketches.memory.Memory srcMem) Gets the approximate upper error bound from a valid memory image of a Sketch given the specified number of Standard Deviations.static CompactSketchheapifyCompactSketch(org.apache.datasketches.memory.Memory srcMem) static CompactSketchheapifyCompactSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static SetOperationheapifySetOperation(org.apache.datasketches.memory.Memory srcMem) static SetOperationheapifySetOperation(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static SketchheapifySketch(org.apache.datasketches.memory.Memory srcMem) static SketchheapifySketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static UpdateSketchheapifyUpdateSketch(org.apache.datasketches.memory.Memory srcMem) static UpdateSketchheapifyUpdateSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static SetOperationBuilderRef:SetOperationBuilderstatic UpdateSketchBuilderRef:UpdateSketchBuilderstatic CompactSketchwrapCompactSketch(org.apache.datasketches.memory.Memory srcMem) static CompactSketchwrapCompactSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static IntersectionwrapIntersection(org.apache.datasketches.memory.Memory srcMem) Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Intersectionstatic IntersectionwrapIntersection(org.apache.datasketches.memory.WritableMemory srcMem) Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Intersectionstatic SetOperationwrapSetOperation(org.apache.datasketches.memory.Memory srcMem) static SetOperationwrapSetOperation(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static SetOperationwrapSetOperation(org.apache.datasketches.memory.WritableMemory srcMem) static SetOperationwrapSetOperation(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed) static SketchwrapSketch(org.apache.datasketches.memory.Memory srcMem) Ref:Sketch.wrap(Memory)static SketchwrapSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) static UnionwrapUnion(org.apache.datasketches.memory.Memory srcMem) Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Unionstatic UnionwrapUnion(org.apache.datasketches.memory.WritableMemory srcMem) Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Unionstatic UpdateSketchwrapUpdateSketch(org.apache.datasketches.memory.WritableMemory srcMem) static UpdateSketchwrapUpdateSketch(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed)
-
Method Details
-
getEstimate
public static double getEstimate(org.apache.datasketches.memory.Memory srcMem) Gets the unique count estimate from a valid memory image of a Sketch- Parameters:
srcMem- See Memory- Returns:
- the sketch's best estimate of the cardinality of the input stream.
-
getLowerBound
public static double getLowerBound(int numStdDev, org.apache.datasketches.memory.Memory srcMem) Gets the approximate lower error bound from a valid memory image of a Sketch given the specified number of Standard Deviations. This will return getEstimate() if isEmpty() is true.- Parameters:
numStdDev- See Number of Standard DeviationssrcMem- See Memory- Returns:
- the lower bound.
-
getMaxAnotBResultBytes
public static int getMaxAnotBResultBytes(int maxNomEntries) Ref:SetOperation.getMaxAnotBResultBytes(int). Returns the maximum number of bytes for the returned CompactSketch, given the maximum value of nomEntries of the first sketch A of AnotB.- Parameters:
maxNomEntries- the given value- Returns:
- the maximum number of bytes.
-
getMaxCompactSketchBytes
public static int getMaxCompactSketchBytes(int numberOfEntries) Returns the maximum number of storage bytes required for a CompactSketch with the given number of actual entries.- Parameters:
numberOfEntries- the actual number of retained entries stored in the sketch.- Returns:
- the maximum number of storage bytes required for a CompactSketch with the given number of retained entries.
-
getCompactSketchMaxBytes
public static int getCompactSketchMaxBytes(int lgNomEntries) Returns the maximum number of storage bytes required for a CompactSketch given the configured log_base2 of the number of nominal entries, which is a power of 2.- Parameters:
lgNomEntries- Nominal Entries- Returns:
- the maximum number of storage bytes required for a CompactSketch with the given lgNomEntries.
- See Also:
-
getMaxIntersectionBytes
public static int getMaxIntersectionBytes(int nomEntries) - Parameters:
nomEntries- Ref:SetOperation.getMaxIntersectionBytes(int),nomEntries- Returns:
- Ref:
SetOperation.getMaxIntersectionBytes(int)
-
getMaxUnionBytes
public static int getMaxUnionBytes(int nomEntries) - Parameters:
nomEntries- Ref:SetOperation.getMaxUnionBytes(int),nomEntries- Returns:
- Ref:
SetOperation.getMaxUnionBytes(int)
-
getMaxUpdateSketchBytes
public static int getMaxUpdateSketchBytes(int nomEntries) - Parameters:
nomEntries- Ref:Sketch.getMaxUpdateSketchBytes(int),nomEntries- Returns:
- Ref:
Sketch.getMaxUpdateSketchBytes(int)
-
getSerializationVersion
public static int getSerializationVersion(org.apache.datasketches.memory.Memory srcMem) - Parameters:
srcMem- Ref:Sketch.getSerializationVersion(Memory),srcMem- Returns:
- Ref:
Sketch.getSerializationVersion(Memory)
-
getUpperBound
public static double getUpperBound(int numStdDev, org.apache.datasketches.memory.Memory srcMem) Gets the approximate upper error bound from a valid memory image of a Sketch given the specified number of Standard Deviations. This will return getEstimate() if isEmpty() is true.- Parameters:
numStdDev- See Number of Standard DeviationssrcMem- See Memory- Returns:
- the upper bound.
-
heapifyCompactSketch
- Parameters:
srcMem- Ref:CompactSketch.heapify(Memory),srcMem- Returns:
CompactSketch
-
heapifyCompactSketch
public static CompactSketch heapifyCompactSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:CompactSketch.heapify(Memory, long),srcMemexpectedSeed- Ref:CompactSketch.heapify(Memory, long),expectedSeed- Returns:
CompactSketch
-
wrapCompactSketch
- Parameters:
srcMem- Ref:CompactSketch.wrap(Memory),srcMem- Returns:
CompactSketch
-
wrapCompactSketch
public static CompactSketch wrapCompactSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:CompactSketch.wrap(Memory, long),srcMemexpectedSeed- Ref:CompactSketch.wrap(Memory, long),expectedSeed- Returns:
CompactSketch
-
heapifySetOperation
- Parameters:
srcMem- Ref:SetOperation.heapify(Memory),srcMem- Returns:
SetOperation
-
heapifySetOperation
public static SetOperation heapifySetOperation(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:SetOperation.heapify(Memory, long),srcMemexpectedSeed- the seed used to validate the given Memory image. Ref:SetOperation.heapify(Memory, long),expectedSeed- Returns:
SetOperation
-
heapifySketch
- Parameters:
srcMem- Ref:Sketch.heapify(Memory),srcMem- Returns:
Sketch
-
heapifySketch
- Parameters:
srcMem- Ref:Sketch.heapify(Memory, long),srcMemexpectedSeed- the seed used to validate the given Memory image. Ref:Sketch.heapify(Memory, long),expectedSeed- Returns:
Sketch
-
heapifyUpdateSketch
- Parameters:
srcMem- Ref:UpdateSketch.heapify(Memory),srcMem- Returns:
UpdateSketch
-
heapifyUpdateSketch
public static UpdateSketch heapifyUpdateSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:UpdateSketch.heapify(Memory, long),srcMemexpectedSeed- the seed used to validate the given Memory image. Ref:UpdateSketch.heapify(Memory, long),expectedSeed- Returns:
UpdateSketch
-
setOperationBuilder
Ref:SetOperationBuilder- Returns:
SetOperationBuilder
-
updateSketchBuilder
Ref:UpdateSketchBuilder- Returns:
UpdateSketchBuilder
-
wrapIntersection
Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Intersection- Parameters:
srcMem- Ref:SetOperation.wrap(Memory),srcMem- Returns:
- a Intersection backed by the given Memory
-
wrapIntersection
Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Intersection- Parameters:
srcMem- Ref:SetOperation.wrap(Memory),srcMem- Returns:
- a Intersection backed by the given Memory
-
wrapSetOperation
- Parameters:
srcMem- Ref:SetOperation.wrap(Memory),srcMem- Returns:
SetOperation
-
wrapSetOperation
public static SetOperation wrapSetOperation(org.apache.datasketches.memory.Memory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:SetOperation.wrap(Memory, long),srcMemexpectedSeed- the seed used to validate the given Memory image. Ref:SetOperation.wrap(Memory, long),expectedSeed- Returns:
SetOperation
-
wrapSetOperation
- Parameters:
srcMem- Ref:SetOperation.wrap(Memory),srcMem- Returns:
SetOperation
-
wrapSetOperation
public static SetOperation wrapSetOperation(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:SetOperation.wrap(Memory, long),srcMemexpectedSeed- the seed used to validate the given Memory image. Ref:SetOperation.wrap(Memory, long),expectedSeed- Returns:
SetOperation
-
wrapSketch
Ref:Sketch.wrap(Memory)- Parameters:
srcMem- Ref:Sketch.wrap(Memory),srcMem- Returns:
Sketch
-
wrapSketch
- Parameters:
srcMem- Ref:Sketch.wrap(Memory, long),srcMemexpectedSeed- the expectedSeed used to validate the given Memory image. Ref:Sketch.wrap(Memory, long),expectedSeed- Returns:
Sketch
-
wrapUnion
Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Union- Parameters:
srcMem- Ref:SetOperation.wrap(Memory),srcMem- Returns:
- a Union backed by the given Memory
-
wrapUnion
Convenience method, callsSetOperation.wrap(Memory)and casts the result to a Union- Parameters:
srcMem- Ref:SetOperation.wrap(Memory),srcMem- Returns:
- a Union backed by the given Memory
-
wrapUpdateSketch
- Parameters:
srcMem- Ref:UpdateSketch.wrap(Memory),srcMem- Returns:
UpdateSketch
-
wrapUpdateSketch
public static UpdateSketch wrapUpdateSketch(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed) - Parameters:
srcMem- Ref:UpdateSketch.wrap(Memory, long),srcMemexpectedSeed- the seed used to validate the given Memory image. Ref:UpdateSketch.wrap(Memory, long),expectedSeed- Returns:
UpdateSketch
-