Package org.apache.datasketches.theta
Class Sketches
- java.lang.Object
-
- org.apache.datasketches.theta.Sketches
-
public final class Sketches extends Object
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
getEstimate(org.apache.datasketches.memory.Memory srcMem)
Gets the unique count estimate from a valid memory image of a Sketchstatic 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.static int
getMaxAnotBResultBytes(int maxNomEntries)
static int
getMaxCompactSketchBytes(int numberOfEntries)
static int
getMaxIntersectionBytes(int nomEntries)
static int
getMaxUnionBytes(int nomEntries)
static int
getMaxUpdateSketchBytes(int nomEntries)
static int
getSerializationVersion(org.apache.datasketches.memory.Memory srcMem)
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.static CompactSketch
heapifyCompactSketch(org.apache.datasketches.memory.Memory srcMem)
static CompactSketch
heapifyCompactSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static SetOperation
heapifySetOperation(org.apache.datasketches.memory.Memory srcMem)
static SetOperation
heapifySetOperation(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static Sketch
heapifySketch(org.apache.datasketches.memory.Memory srcMem)
static Sketch
heapifySketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static UpdateSketch
heapifyUpdateSketch(org.apache.datasketches.memory.Memory srcMem)
static UpdateSketch
heapifyUpdateSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static SetOperationBuilder
setOperationBuilder()
Ref:SetOperationBuilder
static UpdateSketchBuilder
updateSketchBuilder()
Ref:UpdateSketchBuilder
static CompactSketch
wrapCompactSketch(org.apache.datasketches.memory.Memory srcMem)
static CompactSketch
wrapCompactSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static Intersection
wrapIntersection(org.apache.datasketches.memory.Memory srcMem)
Convenience method, callsSetOperation.wrap(Memory)
and casts the result to a Intersectionstatic Intersection
wrapIntersection(org.apache.datasketches.memory.WritableMemory srcMem)
Convenience method, callsSetOperation.wrap(Memory)
and casts the result to a Intersectionstatic SetOperation
wrapSetOperation(org.apache.datasketches.memory.Memory srcMem)
static SetOperation
wrapSetOperation(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static SetOperation
wrapSetOperation(org.apache.datasketches.memory.WritableMemory srcMem)
static SetOperation
wrapSetOperation(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed)
static Sketch
wrapSketch(org.apache.datasketches.memory.Memory srcMem)
Ref:Sketch.wrap(Memory)
static Sketch
wrapSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
static Union
wrapUnion(org.apache.datasketches.memory.Memory srcMem)
Convenience method, callsSetOperation.wrap(Memory)
and casts the result to a Unionstatic Union
wrapUnion(org.apache.datasketches.memory.WritableMemory srcMem)
Convenience method, callsSetOperation.wrap(Memory)
and casts the result to a Unionstatic UpdateSketch
wrapUpdateSketch(org.apache.datasketches.memory.WritableMemory srcMem)
static UpdateSketch
wrapUpdateSketch(org.apache.datasketches.memory.WritableMemory srcMem, long expectedSeed)
-
-
-
Method Detail
-
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)
- Parameters:
numberOfEntries
- Ref:Sketch.getMaxCompactSketchBytes(int)
,numberOfEntries
- Returns:
- Ref:
Sketch.getMaxCompactSketchBytes(int)
-
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
public static CompactSketch heapifyCompactSketch(org.apache.datasketches.memory.Memory srcMem)
- 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)
,srcMem
expectedSeed
- Ref:CompactSketch.heapify(Memory, long)
,expectedSeed
- Returns:
CompactSketch
-
wrapCompactSketch
public static CompactSketch wrapCompactSketch(org.apache.datasketches.memory.Memory srcMem)
- 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)
,srcMem
expectedSeed
- Ref:CompactSketch.wrap(Memory, long)
,expectedSeed
- Returns:
CompactSketch
-
heapifySetOperation
public static SetOperation heapifySetOperation(org.apache.datasketches.memory.Memory srcMem)
- 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)
,srcMem
expectedSeed
- the seed used to validate the given Memory image. Ref:SetOperation.heapify(Memory, long)
,expectedSeed
- Returns:
SetOperation
-
heapifySketch
public static Sketch heapifySketch(org.apache.datasketches.memory.Memory srcMem)
- Parameters:
srcMem
- Ref:Sketch.heapify(Memory)
,srcMem
- Returns:
Sketch
-
heapifySketch
public static Sketch heapifySketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
- Parameters:
srcMem
- Ref:Sketch.heapify(Memory, long)
,srcMem
expectedSeed
- the seed used to validate the given Memory image. Ref:Sketch.heapify(Memory, long)
,expectedSeed
- Returns:
Sketch
-
heapifyUpdateSketch
public static UpdateSketch heapifyUpdateSketch(org.apache.datasketches.memory.Memory srcMem)
- 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)
,srcMem
expectedSeed
- the seed used to validate the given Memory image. Ref:UpdateSketch.heapify(Memory, long)
,expectedSeed
- Returns:
UpdateSketch
-
setOperationBuilder
public static SetOperationBuilder setOperationBuilder()
Ref:SetOperationBuilder
- Returns:
SetOperationBuilder
-
updateSketchBuilder
public static UpdateSketchBuilder updateSketchBuilder()
Ref:UpdateSketchBuilder
- Returns:
UpdateSketchBuilder
-
wrapIntersection
public static Intersection wrapIntersection(org.apache.datasketches.memory.Memory srcMem)
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
public static Intersection wrapIntersection(org.apache.datasketches.memory.WritableMemory srcMem)
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
public static SetOperation wrapSetOperation(org.apache.datasketches.memory.Memory srcMem)
- 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)
,srcMem
expectedSeed
- the seed used to validate the given Memory image. Ref:SetOperation.wrap(Memory, long)
,expectedSeed
- Returns:
SetOperation
-
wrapSetOperation
public static SetOperation wrapSetOperation(org.apache.datasketches.memory.WritableMemory srcMem)
- 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)
,srcMem
expectedSeed
- the seed used to validate the given Memory image. Ref:SetOperation.wrap(Memory, long)
,expectedSeed
- Returns:
SetOperation
-
wrapSketch
public static Sketch wrapSketch(org.apache.datasketches.memory.Memory srcMem)
Ref:Sketch.wrap(Memory)
- Parameters:
srcMem
- Ref:Sketch.wrap(Memory)
,srcMem
- Returns:
Sketch
-
wrapSketch
public static Sketch wrapSketch(org.apache.datasketches.memory.Memory srcMem, long expectedSeed)
- Parameters:
srcMem
- Ref:Sketch.wrap(Memory, long)
,srcMem
expectedSeed
- the expectedSeed used to validate the given Memory image. Ref:Sketch.wrap(Memory, long)
,expectedSeed
- Returns:
Sketch
-
wrapUnion
public static Union wrapUnion(org.apache.datasketches.memory.Memory srcMem)
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
public static Union wrapUnion(org.apache.datasketches.memory.WritableMemory srcMem)
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
public static UpdateSketch wrapUpdateSketch(org.apache.datasketches.memory.WritableMemory srcMem)
- 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)
,srcMem
expectedSeed
- the seed used to validate the given Memory image. Ref:UpdateSketch.wrap(Memory, long)
,expectedSeed
- Returns:
UpdateSketch
-
-