public abstract class UnsafeArrayTypeWriter extends Object implements TypeWriter
supportsUnalignedMemoryAccess
must be set according to the capabilities of the
hardware architecture: the value true
allows more efficient memory access on
architectures that support unaligned memory accesses; the value false
is the safe
fallback that works on every hardware.Modifier and Type | Class and Description |
---|---|
(package private) static class |
UnsafeArrayTypeWriter.Chunk |
Modifier and Type | Field and Description |
---|---|
protected UnsafeArrayTypeWriter.Chunk |
firstChunk |
private static int |
MAX_CHUNK_LENGTH |
private static int |
MIN_CHUNK_LENGTH |
protected int |
totalSize |
protected UnsafeArrayTypeWriter.Chunk |
writeChunk |
Modifier | Constructor and Description |
---|---|
protected |
UnsafeArrayTypeWriter() |
Modifier and Type | Method and Description |
---|---|
static UnsafeArrayTypeWriter |
create(boolean supportsUnalignedMemoryAccess) |
long |
getBytesWritten()
Returns the number of bytes that have been written, i.e., the byte index of the next byte to
be written.
|
void |
putS1(long value)
Writes a signed 1 byte value.
|
void |
putU1(long value)
Writes an unsigned 1 byte value.
|
void |
putU2(long value)
Writes an unsigned 2 byte value.
|
void |
putU4(long value)
Writes an unsigned 4 byte value.
|
byte[] |
toArray(byte[] result)
Copies the buffer into the provided byte[] array of length
getBytesWritten() . |
protected long |
writeOffset(int writeBytes) |
private static final int MIN_CHUNK_LENGTH
private static final int MAX_CHUNK_LENGTH
protected final UnsafeArrayTypeWriter.Chunk firstChunk
protected UnsafeArrayTypeWriter.Chunk writeChunk
protected int totalSize
protected UnsafeArrayTypeWriter()
public static UnsafeArrayTypeWriter create(boolean supportsUnalignedMemoryAccess)
public final long getBytesWritten()
TypeWriter
getBytesWritten
in interface TypeWriter
public final byte[] toArray(byte[] result)
getBytesWritten()
.public final void putS1(long value)
TypeWriter
putS1
in interface TypeWriter
public final void putU1(long value)
TypeWriter
putU1
in interface TypeWriter
public final void putU2(long value)
TypeWriter
putU2
in interface TypeWriter
public final void putU4(long value)
TypeWriter
putU4
in interface TypeWriter
protected long writeOffset(int writeBytes)