final class LittleEndianByteArray
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
LittleEndianByteArray.JavaLittleEndianBytes
Fallback implementation for when Unsafe is not available in our current environment.
|
private static interface |
LittleEndianByteArray.LittleEndianBytes
Common interface for retrieving a 64-bit long from a little-endian byte array.
|
private static class |
LittleEndianByteArray.UnsafeByteArray
The only reference to Unsafe is in this nested class.
|
Modifier and Type | Field and Description |
---|---|
private static LittleEndianByteArray.LittleEndianBytes |
byteArray
The instance that actually does the work; delegates to Unsafe or a pure-Java fallback.
|
Modifier | Constructor and Description |
---|---|
private |
LittleEndianByteArray()
Deter instantiation of this class.
|
Modifier and Type | Method and Description |
---|---|
(package private) static int |
load32(byte[] source,
int offset)
Load 4 bytes from the provided array at the indicated offset.
|
(package private) 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.
|
(package private) static long |
load64Safely(byte[] input,
int offset,
int length)
Similar to load64, but allows offset + 8 > input.length, padding the result with zeroes.
|
(package private) static void |
store64(byte[] sink,
int offset,
long value)
Store 8 bytes into the provided array at the indicated offset, using the value provided.
|
(package private) static boolean |
usingUnsafe()
Indicates that the loading of Unsafe was successful and the load and store operations will be
very efficient.
|
private static final LittleEndianByteArray.LittleEndianBytes byteArray
private LittleEndianByteArray()
static long load64(byte[] input, int offset)
input
- the input bytesoffset
- the offset into the array at which to startstatic long load64Safely(byte[] input, int offset, int length)
input
- the input bytesoffset
- the offset into the array at which to start readinglength
- the number of bytes from the input to readstatic void store64(byte[] sink, int offset, long value)
sink
- the output byte arrayoffset
- the offset into the array at which to start writingvalue
- the value to writestatic int load32(byte[] source, int offset)
input
- the input bytesoffset
- the offset into the array at which to startstatic boolean usingUnsafe()