| Modifier and Type | Class and Description |
|---|---|
| private static enum | LittleEndianByteArray.
Fallback implementation for when Unsafe is not available in our current environment. |
| private static interface | LittleEndianByteArray.
Common interface for retrieving a 64-bit long from a little-endian byte array. |
| private static enum | LittleEndianByteArray.
The only reference to Unsafe is in this nested class. |
| Modifier and Type | Field and Description |
|---|---|
| private static final LittleEndianByteArray. | byteArray
The instance that actually does the work; delegates to Unsafe or a pure-Java fallback. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static int | Returns: the value found in the array in the form of a longthe input bytes source, int the offset into the array at which to start offset)Load 4 bytes from the provided array at the indicated offset. |
| pack-priv static long | Returns: a long of a concatenated 8 bytesthe input bytes input, int the offset into the array at which to start offset)Load 8 bytes into long in a little endian manner, from the substring between position and position + 8. |
| pack-priv static long | Returns: a long of a concatenated 8 bytesthe input bytes input, int the offset into the array at which to start reading offset, int the number of bytes from the input to read length)Similar to load64, but allows offset + 8 > input.length, padding the result with zeroes. |
| pack-priv static void | store64(byte[]
the output byte array sink, int the offset into the array at which to start writing offset, long the value to write value)Store 8 bytes into the provided array at the indicated offset, using the value provided. |
| pack-priv static boolean | usingUnsafe()
Indicates that the loading of Unsafe was successful and the load and store operations will be very efficient. |
| byteArray | back to summary |
|---|---|
| private static final LittleEndianByteArray. The instance that actually does the work; delegates to Unsafe or a pure-Java fallback. | |
| LittleEndianByteArray | back to summary |
|---|---|
| private LittleEndianByteArray() Deter instantiation of this class. | |
| load32 | back to summary |
|---|---|
| pack-priv static int load32(byte[] source, int offset) Load 4 bytes from the provided array at the indicated offset.
| |
| load64 | back to summary |
|---|---|
| pack-priv static long load64(byte[] input, int offset) Load 8 bytes into long in a little endian manner, from the substring between position and position + 8. The array must have at least 8 bytes from offset (inclusive).
| |
| load64Safely | back to summary |
|---|---|
| pack-priv static long load64Safely(byte[] input, int offset, int length) Similar to load64, but allows offset + 8 > input.length, padding the result with zeroes. This has to explicitly reverse the order of the bytes as it packs them into the result which makes it slower than the native version.
| |
| store64 | back to summary |
|---|---|
| pack-priv static void store64(byte[] sink, int offset, long value) Store 8 bytes into the provided array at the indicated offset, using the value provided.
| |
| usingUnsafe | back to summary |
|---|---|
| pack-priv static boolean usingUnsafe() Indicates that the loading of Unsafe was successful and the load and store operations will be very efficient. May be useful for calling code to fall back on an alternative implementation that is slower than Unsafe.get/store but faster than the pure-Java mask-and-shift. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final LittleEndianByteArray. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static LittleEndianByteArray. | |
| public static LittleEndianByteArray. |
| INSTANCE | back to summary |
|---|---|
| public static final LittleEndianByteArray. | |
| JavaLittleEndianBytes | back to summary |
|---|---|
| private JavaLittleEndianBytes() | |
| valueOf | back to summary |
|---|---|
| public static LittleEndianByteArray. | |
| values | back to summary |
|---|---|
| public static LittleEndianByteArray. | |
This abstraction allows us to use single-instruction load and put when available, or fall back on the slower approach of using Longs.fromBytes(byte...).
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public void |
| getLongLittleEndian | back to summary |
|---|---|
| public long getLongLittleEndian(byte[] array, int offset) | |
| putLongLittleEndian | back to summary |
|---|---|
| public void putLongLittleEndian(byte[] array, int offset, long value) | |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final Unsafe | |
| public static final LittleEndianByteArray. | |
| public static final LittleEndianByteArray. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static Unsafe | |
| public static LittleEndianByteArray. | |
| public static LittleEndianByteArray. |
| BYTE_ARRAY_BASE_OFFSET | back to summary |
|---|---|
| private static final int BYTE_ARRAY_BASE_OFFSET | |
| theUnsafe | back to summary |
|---|---|
| private static final Unsafe theUnsafe | |
| UNSAFE_BIG_ENDIAN | back to summary |
|---|---|
| public static final LittleEndianByteArray. | |
| UNSAFE_LITTLE_ENDIAN | back to summary |
|---|---|
| public static final LittleEndianByteArray. | |
| UnsafeByteArray | back to summary |
|---|---|
| private UnsafeByteArray() | |
| getUnsafe | back to summary |
|---|---|
| private static Unsafe getUnsafe() Returns an Unsafe. Suitable for use in a 3rd party package. Replace with a simple call to Unsafe.getUnsafe when integrating into a JDK.
| |
| valueOf | back to summary |
|---|---|
| public static LittleEndianByteArray. | |
| values | back to summary |
|---|---|
| public static LittleEndianByteArray. | |