Enum Class StringEncoding

java.lang.Object
java.lang.Enum<StringEncoding>
org.apache.druid.java.util.common.StringEncoding
All Implemented Interfaces:
Serializable, Comparable<StringEncoding>, Constable, Cacheable

public enum StringEncoding extends Enum<StringEncoding> implements Cacheable
An enum that provides a way for users to specify what encoding should be used when hashing strings. The main reason for this setting's existence is getting the best performance possible. When operating on memory mapped segments -- which store strings as UTF-8 -- it is fastest to use "UTF8". When operating on the result of expressions, or on an in-heap IncrementalIndex -- which use Java strings -- it is fastest to use "UTF16LE". This decision cannot be made locally, because different encodings do not generate equivalent hashes, and therefore they are not mergeable. The decision must be made globally by the end user or by the SQL planner, and should be based on where most input strings are expected to come from. Currently, UTF8 and UTF16LE are the only two options, because there are no situations where other options would be higher-performing.
  • Enum Constant Details

  • Method Details

    • values

      public static StringEncoding[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static StringEncoding valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • fromString

      public static StringEncoding fromString(String name)
    • getCacheKey

      public byte[] getCacheKey()
      Description copied from interface: Cacheable
      Get a byte array used as a cache key.
      Specified by:
      getCacheKey in interface Cacheable
      Returns:
      bytes to be used as cache key - or null if this object should not be cached.
    • toString

      public String toString()
      Overrides:
      toString in class Enum<StringEncoding>