Package tkrzw

Class Utility

Object
Utility

public class Utility extends Object
Library utilities.
  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • parseParams

      public static HashMap<String,String> parseParams(String str)
      Parses a string of parameters in "key=value,key=value" format.
      Parameters:
      str - The string of parameters.
      Returns:
      A map of key-value records.
    • getMemoryCapacity

      public static long getMemoryCapacity()
      Gets the memory capacity of the platform.
      Returns:
      The memory capacity of the platform in bytes, or -1 on failure.
    • getMemoryUsage

      public static long getMemoryUsage()
      Gets the current memory usage of the process.
      Returns:
      The current memory usage of the process in bytes, or -1 on failure.
    • primaryHash

      public static long primaryHash(byte[] data, long num_buckets)
      Primary hash function for the hash database.
      Parameters:
      data - The data to calculate the hash value for.
      num_buckets - The number of buckets of the hash table. If it is 0 or less, the range of the hash value is from Long.MIN_VALUE to Long.MAX_VALUE.
      Returns:
      The hash value.
    • secondaryHash

      public static long secondaryHash(byte[] data, long num_shards)
      Secondaryy hash function for sharding.
      Parameters:
      data - The data to calculate the hash value for.
      num_shards - The number of shards. If it is 0 or less, the range of the hash value is from Long.MIN_VALUE to Long.MAX_VALUE.
      Returns:
      The hash value.
    • editDistanceLev

      public static int editDistanceLev(String a, String b)
      Gets the Levenshtein edit distance of two strings.
      Parameters:
      a - A string.
      b - The other string.
      Returns:
      The Levenshtein edit distance of the two strings.