Class Intersection

  • All Implemented Interfaces:
    MemoryStatus

    public abstract class Intersection
    extends SetOperation
    The API for intersection operations
    Author:
    Lee Rhodes
    • Constructor Detail

      • Intersection

        public Intersection()
    • Method Detail

      • getFamily

        public Family getFamily()
        Description copied from class: SetOperation
        Gets the Family of this SetOperation
        Specified by:
        getFamily in class SetOperation
        Returns:
        the Family of this SetOperation
      • getResult

        public CompactSketch getResult()
        Gets the result of this operation as an ordered CompactSketch on the Java heap. This does not disturb the underlying data structure of this intersection. The intersect(Sketch) method must have been called at least once, otherwise an exception will be thrown. This is because a virgin Intersection object represents the Universal Set, which has an infinite number of values.
        Returns:
        the result of this operation as an ordered CompactSketch on the Java heap
      • getResult

        public abstract CompactSketch getResult​(boolean dstOrdered,
                                                org.apache.datasketches.memory.WritableMemory dstMem)
        Gets the result of this operation as a CompactSketch in the given dstMem. This does not disturb the underlying data structure of this intersection. The intersect(Sketch) method must have been called at least once, otherwise an exception will be thrown. This is because a virgin Intersection object 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 Ordered
        dstMem - See Destination Memory.
        Returns:
        the result of this operation as a CompactSketch stored in the given dstMem, 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 Intersection 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

        public abstract void intersect​(Sketch sketchIn)
        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

        public CompactSketch intersect​(Sketch a,
                                       Sketch b)
        Perform intersect set operation on the two given sketch arguments and return the result as an ordered CompactSketch on the heap.
        Parameters:
        a - The first sketch argument
        b - The second sketch argument
        Returns:
        an ordered CompactSketch on the heap
      • intersect

        public abstract CompactSketch intersect​(Sketch a,
                                                Sketch b,
                                                boolean dstOrdered,
                                                org.apache.datasketches.memory.WritableMemory dstMem)
        Perform intersect set operation on the two given sketches and return the result as a CompactSketch.
        Parameters:
        a - The first sketch argument
        b - The second sketch argument
        dstOrdered - See Destination Ordered.
        dstMem - See Destination Memory.
        Returns:
        the result as a CompactSketch.
      • getMaxLgArrLongs

        protected static int getMaxLgArrLongs​(org.apache.datasketches.memory.Memory dstMem)
        Returns the maximum lgArrLongs given the capacity of the Memory.
        Parameters:
        dstMem - the given Memory
        Returns:
        the maximum lgArrLongs given the capacity of the Memory
      • checkMinSizeMemory

        protected static void checkMinSizeMemory​(org.apache.datasketches.memory.Memory mem)
      • memChecks

        protected static void memChecks​(org.apache.datasketches.memory.Memory srcMem)