Class Union<S extends Summary>

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

public class Union<S extends Summary> extends Object
Compute the union of two or more generic tuple sketches or generic tuple sketches combined with theta sketches. A new instance represents an empty set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Union(int nomEntries, SummarySetOperations<S> summarySetOps)
    Creates new Union instance.
    Union(SummarySetOperations<S> summarySetOps)
    Creates new Union instance with instructions on how to process two summaries that overlap.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the result of a sequence of stateful union operations as an unordered CompactSketch
    getResult(boolean reset)
    Gets the result of a sequence of stateful union operations as an unordered CompactSketch.
    void
    Resets the internal set to the initial state, which represents an empty set.
    void
    union(Sketch thetaSketch, S summary)
    Performs a stateful union 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.
    void
    union(Sketch<S> tupleSketch)
    Performs a stateful union of the internal set with the given tupleSketch.
    union(Sketch<S> tupleSketch, Sketch thetaSketch, S summary)
    Perform a stateless, pair-wise union operation between a tupleSketch and a thetaSketch.
    union(Sketch<S> tupleSketchA, Sketch<S> tupleSketchB)
    Perform a stateless, pair-wise union operation between two tuple sketches.

    Methods inherited from class java.lang.Object

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

    • Union

      public Union(SummarySetOperations<S> summarySetOps)
      Creates new Union instance with instructions on how to process two summaries that overlap. This will have the default nominal entries (K).
      Parameters:
      summarySetOps - instance of SummarySetOperations
    • Union

      public Union(int nomEntries, SummarySetOperations<S> summarySetOps)
      Creates new Union instance.
      Parameters:
      nomEntries - nominal entries (K). Forced to the nearest power of 2 greater than given value.
      summarySetOps - instance of SummarySetOperations
  • Method Details

    • union

      public CompactSketch<S> union(Sketch<S> tupleSketchA, Sketch<S> tupleSketchB)
      Perform a stateless, pair-wise union operation between two tuple sketches. The returned sketch will be cut back to the smaller of the two k values if required.

      Nulls and empty sketches are ignored.

      Parameters:
      tupleSketchA - The first argument
      tupleSketchB - The second argument
      Returns:
      the result ordered CompactSketch on the heap.
    • union

      public CompactSketch<S> union(Sketch<S> tupleSketch, Sketch thetaSketch, S summary)
      Perform a stateless, pair-wise union operation between a tupleSketch and a thetaSketch. The returned sketch will be cut back to the smaller of the two k values if required.

      Nulls and empty sketches are ignored.

      Parameters:
      tupleSketch - The first argument
      thetaSketch - The second argument
      summary - the given proxy summary for the theta sketch, which doesn't have one. This may not be null.
      Returns:
      the result ordered CompactSketch on the heap.
    • union

      public void union(Sketch<S> tupleSketch)
      Performs a stateful union of the internal set with the given tupleSketch.
      Parameters:
      tupleSketch - input tuple sketch to merge with the internal set. Nulls and empty sketches are ignored.
    • union

      public void union(Sketch thetaSketch, S summary)
      Performs a stateful union 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.
      Parameters:
      thetaSketch - the given theta sketch input. If null or empty, it is ignored.
      summary - the given proxy summary for the theta sketch, which doesn't have one. This may not be null.
    • getResult

      public CompactSketch<S> getResult()
      Gets the result of a sequence of stateful union operations as an unordered CompactSketch
      Returns:
      result of the stateful unions so far. The state of this operation is not reset after the result is returned.
    • getResult

      public CompactSketch<S> getResult(boolean reset)
      Gets the result of a sequence of stateful union operations as an unordered CompactSketch.
      Parameters:
      reset - If true, clears this operator to the empty state after this result is returned. Set this to false if you wish to obtain an intermediate result.
      Returns:
      result of the stateful union
    • reset

      public void reset()
      Resets the internal set to the initial state, which represents an empty set. This is only useful after sequences of stateful union operations.