Package org.elasticsearch.common.util
Enum ByteUtils
- java.lang.Object
-
- java.lang.Enum<ByteUtils>
-
- org.elasticsearch.common.util.ByteUtils
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ByteUtils>
,java.lang.constant.Constable
public enum ByteUtils extends java.lang.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 Summary
Fields Modifier and Type Field Description static int
MAX_BYTES_VLONG
-
Method Summary
Modifier and Type Method Description static 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
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ByteUtils[]
values()
Returns an array containing the constants of this enum type, 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 Detail
-
MAX_BYTES_VLONG
public static final int MAX_BYTES_VLONG
- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static ByteUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ByteUtils valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.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.
-
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).
-
-