Enum Class ByteUtils

java.lang.Object
java.lang.Enum<ByteUtils>
org.elasticsearch.common.util.ByteUtils
All Implemented Interfaces:
Serializable, Comparable<ByteUtils>, Constable

public enum ByteUtils extends Enum<ByteUtils>
Utility methods to do byte-level encoding. These methods are biased towards little-endian byte order because it is the most common byte order and reading several bytes at once may be optimizable in the future with the help of sun.mist.Unsafe.
  • Field Details

    • LITTLE_ENDIAN_INT

      public static final VarHandle LITTLE_ENDIAN_INT
    • LITTLE_ENDIAN_LONG

      public static final VarHandle LITTLE_ENDIAN_LONG
  • Method Details

    • values

      public static ByteUtils[] 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 ByteUtils 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
    • zigZagDecode

      public static long zigZagDecode(long n)
      Zig-zag decode.
    • zigZagEncode

      public static long zigZagEncode(long n)
      Zig-zag encode: this helps transforming small signed numbers into small positive numbers.
    • writeLongLE

      public static void writeLongLE(long l, byte[] arr, int offset)
      Write a long in little-endian format.
    • readLongLE

      public static long readLongLE(byte[] arr, int offset)
      Write a long in little-endian format.
    • writeIntLE

      public static void writeIntLE(int l, byte[] arr, int offset)
      Write an int in little-endian format.
    • readIntLE

      public static int readIntLE(byte[] arr, int offset)
      Read an int in little-endian format.
    • writeDoubleLE

      public static void writeDoubleLE(double d, byte[] arr, int offset)
      Write a double in little-endian format.
    • readDoubleLE

      public static double readDoubleLE(byte[] arr, int offset)
      Read a double in little-endian format.
    • writeFloatLE

      public static void writeFloatLE(float d, byte[] arr, int offset)
      Write a float in little-endian format.
    • readFloatLE

      public static float readFloatLE(byte[] arr, int offset)
      Read a float in little-endian format.