Class CpcUnion

java.lang.Object
org.apache.datasketches.cpc.CpcUnion

public class CpcUnion extends Object
The union (merge) operation for the CPC sketches.
Author:
Lee Rhodes, Kevin Lang
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct this unioning object with the default LgK and the default update seed.
    CpcUnion(int lgK)
    Construct this unioning object with LgK and the default update seed.
    CpcUnion(int lgK, long seed)
    Construct this unioning object with LgK and a given seed.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Family
    Return the DataSketches identifier for this CPC family of sketches.
    int
    Returns the current value of Log_base2 of K.
    Returns the result of union operations as a CPC sketch.
    void
    Update this union with a serialized CpcSketch image.
    void
    update(CpcSketch sketch)
    Update this union with a CpcSketch.

    Methods inherited from class Object

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

    • CpcUnion

      public CpcUnion()
      Construct this unioning object with the default LgK and the default update seed.
    • CpcUnion

      public CpcUnion(int lgK)
      Construct this unioning object with LgK and the default update seed.
      Parameters:
      lgK - The given log2 of K.
    • CpcUnion

      public CpcUnion(int lgK, long seed)
      Construct this unioning object with LgK and a given seed.
      Parameters:
      lgK - The given log2 of K.
      seed - The given seed.
  • Method Details

    • update

      public void update(CpcSketch sketch)
      Update this union with a CpcSketch.
      Parameters:
      sketch - the given CpcSketch.
    • update

      public void update(MemorySegment seg)
      Update this union with a serialized CpcSketch image.

      Where possible the image's coupons are decoded straight into this union's bit matrix, which avoids building an intermediate sketch only to walk it once. Images that cannot be decoded that way are uncompressed into a sketch and merged as usual, so the result is the same either way.

      Parameters:
      seg - the given MemorySegment holding a serialized CpcSketch image.
    • getResult

      public CpcSketch getResult()
      Returns the result of union operations as a CPC sketch.
      Returns:
      the result of union operations as a CPC sketch.
    • getLgK

      public int getLgK()
      Returns the current value of Log_base2 of K. Note that due to merging with source sketches that may have a lower value of LgK, this value can be less than what the union object was configured with.
      Returns:
      the current value of Log_base2 of K.
    • getFamily

      public static Family getFamily()
      Return the DataSketches identifier for this CPC family of sketches.
      Returns:
      the DataSketches identifier for this CPC family of sketches.