java.lang.Object
java.lang.Enum<Separator>
org.apache.hadoop.yarn.server.timelineservice.storage.common.Separator
All Implemented Interfaces:
Serializable, Comparable<Separator>, Constable

public enum Separator extends Enum<Separator>
Used to separate row qualifiers, column qualifiers and compound fields.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    separator in key or column qualifier fields.
    separator in values, often used to avoid having these in qualifiers and names.
    separator in values, often used to avoid having these in qualifiers and names.
    separator in values, and/or compound key/column qualifier fields.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte[]
    empty bytes.
    static final String
    empty string.
    static final int
    Indicator for variable size of an individual segment in a split.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    decode(byte[] token, Separator... separators)
    Decode the given separators in the token with their decoding equivalents.
    decode(String token)
    Decode the token encoded using encode(String).
    static String
    decode(String token, Separator... separators)
    Decode the given separators in the token with their decoding equivalents.
    encode(String token)
    Used to make token safe to be used with this separator without collisions.
    static byte[]
    encode(String token, Separator... separators)
    Encode the given separators in the token with their encoding equivalents.
     
    byte[]
    join(byte[]... components)
    Returns a single byte array containing all of the individual arrays components separated by this separator.
    Concatenates items (as String), using this separator.
    joinEncoded(String... items)
    Concatenates items (as String), using this separator.
    byte[][]
    split(byte[] source)
    Splits the source array into multiple array segments using this separator, as many times as splits are found.
    byte[][]
    split(byte[] source, int limit)
    Splits the source array into multiple array segments using this separator, up to a maximum of count items.
    byte[][]
    split(byte[] source, int[] sizes)
    Splits the source array into multiple array segments using this separator.
    splitEncoded(String compoundValue)
     
    static Separator
    Returns the enum constant of this class with the specified name.
    static Separator[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • QUALIFIERS

      public static final Separator QUALIFIERS
      separator in key or column qualifier fields.
    • VALUES

      public static final Separator VALUES
      separator in values, and/or compound key/column qualifier fields.
    • SPACE

      public static final Separator SPACE
      separator in values, often used to avoid having these in qualifiers and names. Note that if we use HTML form encoding through URLEncoder, we end up getting a + for a space, which may already occur in strings, so we don't want that.
    • TAB

      public static final Separator TAB
      separator in values, often used to avoid having these in qualifiers and names.
  • Field Details

    • VARIABLE_SIZE

      public static final int VARIABLE_SIZE
      Indicator for variable size of an individual segment in a split. The segment ends wherever separator is encountered. Typically used for string. Also used to indicate that there is no fixed number of splits which need to be returned. If split limit is specified as this, all possible splits are returned.
      See Also:
    • EMPTY_STRING

      public static final String EMPTY_STRING
      empty string.
      See Also:
    • EMPTY_BYTES

      public static final byte[] EMPTY_BYTES
      empty bytes.
  • Method Details

    • values

      public static Separator[] 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 Separator 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
    • getValue

      public String getValue()
      Returns:
      the original value of the separator
    • encode

      public String encode(String token)
      Used to make token safe to be used with this separator without collisions. It must be paired with decode(String) for it to be decoded correctly.

      If you need to encode a given string for multiple separators, encode(String, Separator...) should be used over successive invocations of this method. It will result in a more compact version of the encoded value.

      Parameters:
      token - Token to be encoded.
      Returns:
      the token with any occurrences of this separator URLEncoded.
    • decode

      public String decode(String token)
      Decode the token encoded using encode(String). It must be used for the result encoded with encode(String) to be able to recover the original.
      Parameters:
      token - Token to be decoded.
      Returns:
      the token with any occurrences of the encoded separator replaced by the separator itself.
    • encode

      public static byte[] encode(String token, Separator... separators)
      Encode the given separators in the token with their encoding equivalents. It must be paired with decode(byte[], Separator...) or decode(String, Separator...) with the same separators for it to be decoded correctly.

      If you need to encode a given string for multiple separators, this form of encoding should be used over successive invocations of encode(String). It will result in a more compact version of the encoded value.

      Parameters:
      token - containing possible separators that need to be encoded.
      separators - to be encoded in the token with their URLEncoding equivalent.
      Returns:
      non-null byte representation of the token with occurrences of the separators encoded.
    • decode

      public static String decode(byte[] token, Separator... separators)
      Decode the given separators in the token with their decoding equivalents. It must be used for the result encoded with encode(String, Separator...) with the same separators to be able to recover the original.
      Parameters:
      token - containing possible separators that need to be encoded.
      separators - to be encoded in the token with their URLEncoding equivalent.
      Returns:
      String representation of the token with occurrences of the URL encoded separators decoded.
    • decode

      public static String decode(String token, Separator... separators)
      Decode the given separators in the token with their decoding equivalents. It must be used for the result encoded with encode(String, Separator...) with the same separators to be able to recover the original.
      Parameters:
      token - containing possible separators that need to be encoded.
      separators - to be encoded in the token with their URLEncoding equivalent.
      Returns:
      String representation of the token with occurrences of the URL encoded separators decoded.
    • join

      public byte[] join(byte[]... components)
      Returns a single byte array containing all of the individual arrays components separated by this separator.
      Parameters:
      components - Byte array components to be joined together.
      Returns:
      byte array after joining the components
    • joinEncoded

      public String joinEncoded(String... items)
      Concatenates items (as String), using this separator.
      Parameters:
      items - Items join, toString() will be called in each item. Any occurrence of the separator in the individual strings will be first encoded. Cannot be null.
      Returns:
      non-null joined result. Note that when separator is null the result is simply all items concatenated and the process is not reversible through splitEncoded(String)
    • joinEncoded

      public String joinEncoded(Iterable<?> items)
      Concatenates items (as String), using this separator.
      Parameters:
      items - Items join, toString() will be called in each item. Any occurrence of the separator in the individual strings will be first encoded. Cannot be null.
      Returns:
      non-null joined result. Note that when separator is null the result is simply all items concatenated and the process is not reversible through splitEncoded(String)
    • splitEncoded

      public Collection<String> splitEncoded(String compoundValue)
      Parameters:
      compoundValue - containing individual values separated by this separator, which have that separator encoded.
      Returns:
      non-null set of values from the compoundValue with the separator decoded.
    • split

      public byte[][] split(byte[] source, int limit)
      Splits the source array into multiple array segments using this separator, up to a maximum of count items. This will naturally produce copied byte arrays for each of the split segments.
      Parameters:
      source - to be split
      limit - on how many segments are supposed to be returned. A non-positive value indicates no limit on number of segments.
      Returns:
      source split by this separator.
    • split

      public byte[][] split(byte[] source, int[] sizes)
      Splits the source array into multiple array segments using this separator. The sizes indicate the sizes of the relative components/segments. In case one of the segments contains this separator before the specified size is reached, the separator will be considered part of that segment and we will continue till size is reached. Variable length strings cannot contain this separator and are indiced with a size of 0. Such strings are encoded for this separator and decoded after the results from split is returned.
      Parameters:
      source - byte array to be split.
      sizes - sizes of relative components/segments.
      Returns:
      source split by this separator as per the sizes specified..
    • split

      public byte[][] split(byte[] source)
      Splits the source array into multiple array segments using this separator, as many times as splits are found. This will naturally produce copied byte arrays for each of the split segments.
      Parameters:
      source - byte array to be split
      Returns:
      source split by this separator.