Class Util

java.lang.Object
org.apache.datasketches.tuple.Util

public final class Util extends Object
Common utility functions for Tuples
  • Constructor Summary

    Constructors
    Constructor
    Description
    No argument constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <S extends Summary>
    S[]
    copySummaryArray(S[] summaryArr)
    Will copy compact summary arrays as well as hashed summary tables (with nulls).
    static final long[]
    doubleToLongArray(double value)
    Converts a double to a long[].
    static int
    getStartingCapacity(int nomEntries, int lgResizeFactor)
    Gets the starting capacity of a new sketch given the Nominal Entries and the log Resize Factor.
    static <S extends Summary>
    S[]
    newSummaryArray(S[] summaryArr, int length)
    Creates a new Summary Array with the specified length
    static long
    stringArrHash(String[] strArray)
    Returns the hash of the concatenated strings
    static String
    stringConcat(String[] strArr)
    Concatenate array of Strings to a single String.
    static long
    Returns the hash of the given string
    static final byte[]
    Converts a String to a UTF_8 byte array.

    Methods inherited from class Object

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

    • Util

      public Util()
      No argument constructor.
  • Method Details

    • doubleToLongArray

      public static final long[] doubleToLongArray(double value)
      Converts a double to a long[].
      Parameters:
      value - the given double value
      Returns:
      the long array
    • stringToByteArray

      public static final byte[] stringToByteArray(String value)
      Converts a String to a UTF_8 byte array. If the given value is either null or empty this method returns null.
      Parameters:
      value - the given String value
      Returns:
      the UTF_8 byte array
    • getStartingCapacity

      public static int getStartingCapacity(int nomEntries, int lgResizeFactor)
      Gets the starting capacity of a new sketch given the Nominal Entries and the log Resize Factor.
      Parameters:
      nomEntries - the given Nominal Entries
      lgResizeFactor - the given log Resize Factor
      Returns:
      the starting capacity
    • stringConcat

      public static String stringConcat(String[] strArr)
      Concatenate array of Strings to a single String.
      Parameters:
      strArr - the given String array
      Returns:
      the concatenated String
    • stringHash

      public static long stringHash(String s)
      Returns the hash of the given string
      Parameters:
      s - the string to hash
      Returns:
      the hash of the given string
    • stringArrHash

      public static long stringArrHash(String[] strArray)
      Returns the hash of the concatenated strings
      Parameters:
      strArray - array of Strings
      Returns:
      the hash of concatenated strings.
    • copySummaryArray

      public static <S extends Summary> S[] copySummaryArray(S[] summaryArr)
      Will copy compact summary arrays as well as hashed summary tables (with nulls).
      Type Parameters:
      S - type of summary
      Parameters:
      summaryArr - the given summary array or table
      Returns:
      the copy
    • newSummaryArray

      public static <S extends Summary> S[] newSummaryArray(S[] summaryArr, int length)
      Creates a new Summary Array with the specified length
      Type Parameters:
      S - the summary class type
      Parameters:
      summaryArr - example array, only used to obtain the component type. It has no data.
      length - the desired length of the returned array.
      Returns:
      a new Summary Array with the specified length