Class TupleIntersection<S extends Summary>

java.lang.Object
org.apache.datasketches.tuple.TupleIntersection<S>
Type Parameters:
S - Type of Summary

public class TupleIntersection<S extends Summary> extends Object
Computes an intersection of two or more generic TupleSketches or generic TupleSketches combined with ThetaSketches. 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
    Creates new TupleIntersection instance with instructions on how to process two summaries that intersect.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the internal set as an unordered CompactTupleSketch
    boolean
    Returns true if there is a valid intersection result available
    void
    intersect(ThetaSketch thetaSketch, S summary)
    Performs a stateful intersection of the internal set with the given ThetaSketch by combining entries using the hashes from the ThetaSketch and summary values from the given summary and rules from the summarySetOps defined by the TupleIntersection constructor.
    void
    intersect(TupleSketch<S> tupleSketch)
    Performs a stateful intersection of the internal set with the given TupleSketch.
    intersect(TupleSketch<S> tupleSketch, ThetaSketch thetaSketch, S summary)
    Perform a stateless intersect set operation on a TupleSketch and a ThetaSketch and returns the result as an unordered CompactTupleSketch on the heap.
    intersect(TupleSketch<S> tupleSketchA, TupleSketch<S> tupleSketchB)
    Perform a stateless intersect set operation on the two given TupleSketches and returns the result as an unordered CompactTupleSketch on the heap.
    void
    Resets the internal set to the initial state, which represents the Universal Set

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TupleIntersection

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

    • intersect

      public CompactTupleSketch<S> intersect(TupleSketch<S> tupleSketchA, TupleSketch<S> tupleSketchB)
      Perform a stateless intersect set operation on the two given TupleSketches and returns the result as an unordered CompactTupleSketch 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 CompactTupleSketch on the heap
    • intersect

      public CompactTupleSketch<S> intersect(TupleSketch<S> tupleSketch, ThetaSketch thetaSketch, S summary)
      Perform a stateless intersect set operation on a TupleSketch and a ThetaSketch and returns the result as an unordered CompactTupleSketch 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 ThetaSketch, which doesn't have one. This must not be null.
      Returns:
      an unordered CompactTupleSketch on the heap
    • intersect

      public void intersect(TupleSketch<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(ThetaSketch thetaSketch, S summary)
      Performs a stateful intersection of the internal set with the given ThetaSketch by combining entries using the hashes from the ThetaSketch and summary values from the given summary and rules from the summarySetOps defined by the TupleIntersection constructor.
      Parameters:
      thetaSketch - input ThetaSketch 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 CompactTupleSketch<S> getResult()
      Gets the internal set as an unordered CompactTupleSketch
      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