Class ThetaIntersection
java.lang.Object
org.apache.datasketches.theta.ThetaSetOperation
org.apache.datasketches.theta.ThetaIntersection
- All Implemented Interfaces:
MemorySegmentStatus
The API for intersection operations
- Author:
- Lee Rhodes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the Family of this ThetaSetOperationGets the result of this operation as an ordered CompactThetaSketch on the Java heap.abstract CompactThetaSketchgetResult(boolean dstOrdered, MemorySegment dstSeg) Gets the result of this operation as a CompactThetaSketch in the given dstSeg.abstract booleanReturns true if there is a valid intersection result availableabstract voidintersect(ThetaSketch sketchIn) Intersect the given sketch with the internal state.intersect(ThetaSketch a, ThetaSketch b) Perform intersect set operation on the two given sketch arguments and return the result as an ordered CompactThetaSketch on the heap.abstract CompactThetaSketchintersect(ThetaSketch a, ThetaSketch b, boolean dstOrdered, MemorySegment dstSeg) Perform intersect set operation on the two given sketches and return the result as a CompactThetaSketch.abstract voidreset()Resets this ThetaIntersection for stateful operations only.abstract byte[]Serialize this intersection to a byte array form.static ThetaIntersectionwrap(MemorySegment srcSeg) Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data.static ThetaIntersectionwrap(MemorySegment srcSeg, long expectedSeed) Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data.Methods inherited from class ThetaSetOperation
builder, getMaxAnotBResultBytes, getMaxIntersectionBytes, getMaxUnionBytes, heapify, heapifyMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MemorySegmentStatus
hasMemorySegment, isOffHeap, isSameResource
-
Constructor Details
-
ThetaIntersection
public ThetaIntersection()No argument constructor.
-
-
Method Details
-
getFamily
Description copied from class:ThetaSetOperationGets the Family of this ThetaSetOperation- Specified by:
getFamilyin classThetaSetOperation- Returns:
- the Family of this ThetaSetOperation
-
getResult
Gets the result of this operation as an ordered CompactThetaSketch on the Java heap. This does not disturb the underlying data structure of this intersection. Theintersect(ThetaSketch)method must have been called at least once, otherwise an exception will be thrown. This is because a virgin intersection represents the Universal Set, which has an infinite number of values.- Returns:
- the result of this operation as an ordered CompactThetaSketch on the Java heap
-
getResult
Gets the result of this operation as a CompactThetaSketch in the given dstSeg. This does not disturb the underlying data structure of this intersection. Theintersect(ThetaSketch)method must have been called at least once, otherwise an exception will be thrown. This is because a virgin intersection represents the Universal Set, which has an infinite number of values.Note that presenting an intersection with an empty sketch sets the internal state of the intersection to empty = true, and current count = 0. This is consistent with the mathematical definition of the intersection of any set with the empty set is always empty.
Presenting an intersection with a null argument will throw an exception.
- Parameters:
dstOrdered- See Destination OrdereddstSeg- the destination MemorySegment.- Returns:
- the result of this operation as a CompactThetaSketch stored in the given dstSeg, which can be either on or off-heap..
-
hasResult
public abstract boolean hasResult()Returns true if there is a valid intersection result available- Returns:
- true if there is a valid intersection result available
-
reset
public abstract void reset()Resets this ThetaIntersection for stateful operations only. The seed remains intact, otherwise reverts to the Universal Set: theta = 1.0, no retained data and empty = false. -
toByteArray
public abstract byte[] toByteArray()Serialize this intersection to a byte array form.- Returns:
- byte array of this intersection
-
intersect
Intersect the given sketch with the internal state. This method can be repeatedly called. If the given sketch is null the internal state becomes the empty sketch. Theta will become the minimum of thetas seen so far.- Parameters:
sketchIn- the given sketch
-
intersect
Perform intersect set operation on the two given sketch arguments and return the result as an ordered CompactThetaSketch on the heap.- Parameters:
a- The first sketch argumentb- The second sketch argument- Returns:
- an ordered CompactThetaSketch on the heap
-
intersect
public abstract CompactThetaSketch intersect(ThetaSketch a, ThetaSketch b, boolean dstOrdered, MemorySegment dstSeg) Perform intersect set operation on the two given sketches and return the result as a CompactThetaSketch.- Parameters:
a- The first sketch argumentb- The second sketch argumentdstOrdered- See Destination Ordered.dstSeg- the destination MemorySegment.- Returns:
- the result as a CompactThetaSketch.
-
wrap
Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data. This method assumes the Default Update Seed. If the given source MemorySegment is read-only, the returned object will also be read-only.- Parameters:
srcSeg- The source MemorySegment image.- Returns:
- a ThetaIntersection that wraps a source MemorySegment that contains a ThetaIntersection image
-
wrap
Factory: Wrap a ThetaIntersection target around the given source MemorySegment containing intersection data. If the given source MemorySegment is read-only, the returned object will also be read-only.- Parameters:
srcSeg- The source MemorySegment image.expectedSeed- See seed- Returns:
- a ThetaIntersection that wraps a source MemorySegment that contains a ThetaIntersection image
-