Package org.elasticsearch.common.util
Enum Class ByteUtils
- All Implemented Interfaces:
Serializable
,Comparable<ByteUtils>
,Constable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
readDoubleLE(byte[] arr, int offset)
Read a double in little-endian format.static float
readFloatLE(byte[] arr, int offset)
Read a float in little-endian format.static int
readIntLE(byte[] arr, int offset)
Read an int in little-endian format.static long
readLongLE(byte[] arr, int offset)
Write a long in little-endian format.static long
readVLong(org.apache.lucene.store.ByteArrayDataInput in)
Same as DataOutput#readVLong but can read negative values (read on 9 bytes).static ByteUtils
Returns the enum constant of this class with the specified name.static ByteUtils[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.static void
writeDoubleLE(double d, byte[] arr, int offset)
Write a double in little-endian format.static void
writeFloatLE(float d, byte[] arr, int offset)
Write a float in little-endian format.static void
writeIntLE(int l, byte[] arr, int offset)
Write an int in little-endian format.static void
writeLongLE(long l, byte[] arr, int offset)
Write a long in little-endian format.static void
writeVLong(org.apache.lucene.store.ByteArrayDataOutput out, long i)
Same as DataOutput#writeVLong but accepts negative values (written on 9 bytes).static long
zigZagDecode(long n)
Zig-zag decode.static long
zigZagEncode(long n)
Zig-zag encode: this helps transforming small signed numbers into small positive numbers.
-
Field Details
-
MAX_BYTES_VLONG
public static final int MAX_BYTES_VLONG- See Also:
- Constant Field Values
-
-
Method Details
-
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
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 nameNullPointerException
- 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. -
writeVLong
public static void writeVLong(org.apache.lucene.store.ByteArrayDataOutput out, long i)Same as DataOutput#writeVLong but accepts negative values (written on 9 bytes). -
readVLong
public static long readVLong(org.apache.lucene.store.ByteArrayDataInput in)Same as DataOutput#readVLong but can read negative values (read on 9 bytes).
-