Class ArrayOfStringsSketch

Direct Known Subclasses:
FdtSketch

public class ArrayOfStringsSketch
extends UpdatableSketch<String[],​ArrayOfStringsSummary>
Author:
Lee Rhodes
  • Field Summary

    Fields inherited from class org.apache.datasketches.tuple.Sketch

    PREAMBLE_LONGS
  • Constructor Summary

    Constructors 
    Constructor Description
    ArrayOfStringsSketch()
    Constructs new sketch with default K = 4096 (lgK = 12), default ResizeFactor=X8, and default p = 1.0.
    ArrayOfStringsSketch​(int lgK)
    Constructs new sketch with default ResizeFactor=X8, default p = 1.0 and given lgK.
    ArrayOfStringsSketch​(int lgK, ResizeFactor rf, float p)
    Constructs new sketch with given ResizeFactor, p and lgK.
    ArrayOfStringsSketch​(org.apache.datasketches.memory.Memory mem)
    Constructs this sketch from a Memory image, which must be from an ArrayOfStringsSketch, and usually with data.
  • Method Summary

    Modifier and Type Method Description
    CompactSketch<S> compact()
    Converts the current state of the sketch into a compact sketch
    int getCountLessThanThetaLong​(long thetaLong)
    Gets the number of hash values less than the given theta expressed as a long.
    int getCurrentCapacity()
    Get current capacity
    int getLgK()
    Get log_base2 of Nominal Entries
    int getNominalEntries()
    Get configured nominal number of entries
    ResizeFactor getResizeFactor()
    Get configured resize factor
    int getRetainedEntries()  
    float getSamplingProbability()
    Get configured sampling probability
    protected void insertSummary​(int index, S summary)  
    SketchIterator<S> iterator()
    Returns a SketchIterator
    void reset()
    Resets this sketch an empty state.
    byte[] toByteArray()
    This is to serialize an instance to a byte array.
    void trim()
    Rebuilds reducing the actual number of entries to the nominal number of entries if needed
    void update​(String[] strArrKey, String[] strArr)
    Updates the sketch with String arrays for both key and value.

    Methods inherited from class org.apache.datasketches.tuple.UpdatableSketch

    update, update, update, update, update, update

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ArrayOfStringsSketch

      public ArrayOfStringsSketch()
      Constructs new sketch with default K = 4096 (lgK = 12), default ResizeFactor=X8, and default p = 1.0.
    • ArrayOfStringsSketch

      public ArrayOfStringsSketch​(int lgK)
      Constructs new sketch with default ResizeFactor=X8, default p = 1.0 and given lgK.
      Parameters:
      lgK - Log_base2 of Nominal Entries. See Nominal Entries
    • ArrayOfStringsSketch

      public ArrayOfStringsSketch​(int lgK, ResizeFactor rf, float p)
      Constructs new sketch with given ResizeFactor, p and lgK.
      Parameters:
      lgK - Log_base2 of Nominal Entries. See Nominal Entries
      rf - ResizeFactor See Resize Factor
      p - sampling probability See Sampling Probability
    • ArrayOfStringsSketch

      public ArrayOfStringsSketch​(org.apache.datasketches.memory.Memory mem)
      Constructs this sketch from a Memory image, which must be from an ArrayOfStringsSketch, and usually with data.
      Parameters:
      mem - the given Memory
  • Method Details

    • update

      public void update​(String[] strArrKey, String[] strArr)
      Updates the sketch with String arrays for both key and value.
      Parameters:
      strArrKey - the given String array key
      strArr - the given String array value
    • getRetainedEntries

      public int getRetainedEntries()
      Specified by:
      getRetainedEntries in class Sketch<S extends Summary>
      Returns:
      number of retained entries
    • getCountLessThanThetaLong

      public int getCountLessThanThetaLong​(long thetaLong)
      Description copied from class: Sketch
      Gets the number of hash values less than the given theta expressed as a long.
      Specified by:
      getCountLessThanThetaLong in class Sketch<S extends Summary>
      Parameters:
      thetaLong - the given theta as a long between zero and Long.MAX_VALUE.
      Returns:
      the number of hash values less than the given thetaLong.
    • getNominalEntries

      public int getNominalEntries()
      Get configured nominal number of entries
      Returns:
      nominal number of entries
    • getLgK

      public int getLgK()
      Get log_base2 of Nominal Entries
      Returns:
      log_base2 of Nominal Entries
    • getSamplingProbability

      public float getSamplingProbability()
      Get configured sampling probability
      Returns:
      sampling probability
    • getCurrentCapacity

      public int getCurrentCapacity()
      Get current capacity
      Returns:
      current capacity
    • getResizeFactor

      public ResizeFactor getResizeFactor()
      Get configured resize factor
      Returns:
      resize factor
    • trim

      public void trim()
      Rebuilds reducing the actual number of entries to the nominal number of entries if needed
    • reset

      public void reset()
      Resets this sketch an empty state.
    • compact

      public CompactSketch<S> compact()
      Converts the current state of the sketch into a compact sketch
      Specified by:
      compact in class Sketch<S extends Summary>
      Returns:
      compact sketch
    • toByteArray

      public byte[] toByteArray()
      Description copied from class: Sketch
      This is to serialize an instance to a byte array.
      Specified by:
      toByteArray in class Sketch<S extends Summary>
      Returns:
      serialized representation of the sketch
    • insertSummary

      protected void insertSummary​(int index, S summary)
    • iterator

      public SketchIterator<S> iterator()
      Description copied from class: Sketch
      Returns a SketchIterator
      Specified by:
      iterator in class Sketch<S extends Summary>
      Returns:
      a SketchIterator