Class Intersection<S extends Summary>

  • Type Parameters:
    S - Type of Summary

    public class Intersection<S extends Summary>
    extends Object
    Computes an intersection of two or more generic tuple sketches or generic tuple sketches combined with theta sketches. A new instance represents the Universal Set. Because the Universal Set cannot be realized a getResult() on a new instance will produce an error. Every update() computes an intersection with the internal state, which will never grow larger and may be reduced to zero.
    • Constructor Summary

      Constructors 
      Constructor Description
      Intersection​(SummarySetOperations<S> summarySetOps)
      Creates new Intersection instance with instructions on how to process two summaries that intersect.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CompactSketch<S> getResult()
      Gets the internal set as an unordered CompactSketch
      boolean hasResult()
      Returns true if there is a valid intersection result available
      void intersect​(Sketch thetaSketch, S summary)
      Performs a stateful intersection of the internal set with the given thetaSketch by combining entries using the hashes from the theta sketch and summary values from the given summary and rules from the summarySetOps defined by the Intersection constructor.
      void intersect​(Sketch<S> tupleSketch)
      Performs a stateful intersection of the internal set with the given tupleSketch.
      CompactSketch<S> intersect​(Sketch<S> tupleSketch, Sketch thetaSketch, S summary)
      Perform a stateless intersect set operation on a tuple sketch and a theta sketch and returns the result as an unordered CompactSketch on the heap.
      CompactSketch<S> intersect​(Sketch<S> tupleSketchA, Sketch<S> tupleSketchB)
      Perform a stateless intersect set operation on the two given tuple sketches and returns the result as an unordered CompactSketch on the heap.
      void reset()
      Resets the internal set to the initial state, which represents the Universal Set
    • Constructor Detail

      • Intersection

        public Intersection​(SummarySetOperations<S> summarySetOps)
        Creates new Intersection instance with instructions on how to process two summaries that intersect.
        Parameters:
        summarySetOps - instance of SummarySetOperations
    • Method Detail

      • intersect

        public CompactSketch<S> intersect​(Sketch<S> tupleSketchA,
                                          Sketch<S> tupleSketchB)
        Perform a stateless intersect set operation on the two given tuple sketches and returns the result as an unordered CompactSketch on the heap.
        Parameters:
        tupleSketchA - The first sketch argument. It must not be null.
        tupleSketchB - The second sketch argument. It must not be null.
        Returns:
        an unordered CompactSketch on the heap
      • intersect

        public CompactSketch<S> intersect​(Sketch<S> tupleSketch,
                                          Sketch thetaSketch,
                                          S summary)
        Perform a stateless intersect set operation on a tuple sketch and a theta sketch and returns the result as an unordered CompactSketch on the heap.
        Parameters:
        tupleSketch - The first sketch argument. It must not be null.
        thetaSketch - The second sketch argument. It must not be null.
        summary - the given proxy summary for the theta sketch, which doesn't have one. This must not be null.
        Returns:
        an unordered CompactSketch on the heap
      • intersect

        public void intersect​(Sketch<S> tupleSketch)
        Performs a stateful intersection of the internal set with the given tupleSketch.
        Parameters:
        tupleSketch - input sketch to intersect with the internal state. It must not be null.
      • intersect

        public void intersect​(Sketch thetaSketch,
                              S summary)
        Performs a stateful intersection of the internal set with the given thetaSketch by combining entries using the hashes from the theta sketch and summary values from the given summary and rules from the summarySetOps defined by the Intersection constructor.
        Parameters:
        thetaSketch - input theta sketch to intersect with the internal state. It must not be null.
        summary - the given proxy summary for the theta sketch, which doesn't have one. It will be copied for each matching index. It must not be null.
      • getResult

        public CompactSketch<S> getResult()
        Gets the internal set as an unordered CompactSketch
        Returns:
        result of the intersections so far
      • hasResult

        public boolean hasResult()
        Returns true if there is a valid intersection result available
        Returns:
        true if there is a valid intersection result available
      • reset

        public void reset()
        Resets the internal set to the initial state, which represents the Universal Set