Package one.microstream.memory.sun
Class JdkMemoryAccessor
- java.lang.Object
-
- one.microstream.memory.sun.JdkMemoryAccessor
-
- All Implemented Interfaces:
MemoryAccessor
,MemorySizeProperties
public final class JdkMemoryAccessor extends Object implements MemoryAccessor, MemorySizeProperties
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface one.microstream.memory.MemorySizeProperties
MemorySizeProperties.Unsupported
-
-
Constructor Summary
Constructors Constructor Description JdkMemoryAccessor()
-
Method Summary
Modifier and Type Method Description long
allocateMemory(long bytes)
byte[]
asByteArray(long value)
byte[]
asByteArray(long[] values)
long
byteSizeArray_boolean(long elementCount)
long
byteSizeArray_byte(long elementCount)
long
byteSizeArray_char(long elementCount)
long
byteSizeArray_double(long elementCount)
long
byteSizeArray_float(long elementCount)
long
byteSizeArray_int(long elementCount)
long
byteSizeArray_long(long elementCount)
long
byteSizeArray_short(long elementCount)
long
byteSizeArrayObject(long elementCount)
int
byteSizeFieldValue(Class<?> type)
int
byteSizeInstance(Class<?> type)
int
byteSizeObjectHeader(Class<?> type)
int
byteSizeReference()
void
copyArrayToAddress(boolean[] array, long targetAddress)
void
copyArrayToAddress(byte[] array, long targetAddress)
void
copyArrayToAddress(char[] array, long targetAddress)
void
copyArrayToAddress(double[] array, long targetAddress)
void
copyArrayToAddress(float[] array, long targetAddress)
void
copyArrayToAddress(int[] array, long targetAddress)
void
copyArrayToAddress(long[] array, long targetAddress)
void
copyArrayToAddress(short[] array, long targetAddress)
void
copyRange(long sourceAddress, long targetAddress, long length)
void
copyRangeToArray(long sourceAddress, boolean[] target)
void
copyRangeToArray(long sourceAddress, byte[] target)
void
copyRangeToArray(long sourceAddress, char[] target)
void
copyRangeToArray(long sourceAddress, double[] target)
void
copyRangeToArray(long sourceAddress, float[] target)
void
copyRangeToArray(long sourceAddress, int[] target)
void
copyRangeToArray(long sourceAddress, long[] target)
void
copyRangeToArray(long sourceAddress, short[] target)
boolean
deallocateDirectByteBuffer(ByteBuffer directBuffer)
void
ensureClassInitialized(Class<?> c)
void
ensureClassInitialized(Class<?> c, Iterable<Field> usedFields)
Uses the passed fields if required by the implementation.void
fillMemory(long address, long length, byte value)
void
freeMemory(long address)
boolean
get_boolean(long address)
boolean
get_boolean(Object instance, long offset)
byte
get_byte(long address)
byte
get_byte(Object instance, long offset)
char
get_char(long address)
char
get_char(Object instance, long offset)
double
get_double(long address)
double
get_double(Object instance, long offset)
float
get_float(long address)
float
get_float(Object instance, long offset)
int
get_int(long address)
int
get_int(Object instance, long offset)
long
get_long(long address)
long
get_long(Object instance, long offset)
short
get_short(long address)
short
get_short(Object instance, long offset)
long
getDirectByteBufferAddress(ByteBuffer directBuffer)
Object
getObject(Object instance, long offset)
ByteBuffer
guaranteeDirectByteBuffer(ByteBuffer directBuffer)
void
guaranteeUsability()
Guarantees the full usability of this class by validating if all functionality is usable.<T> T
instantiateBlank(Class<T> c)
boolean
isDirectByteBuffer(ByteBuffer byteBuffer)
static JdkMemoryAccessor
New()
long
objectFieldOffset(Class<?> objectClass, Field field)
Similar toMemoryAccessor.objectFieldOffset(Field)
, but with the specific object class.
The difference is that the actual object's class is not the declaring class of its fields if it only extends another class but does not declare an object field itself.long
objectFieldOffset(Field field)
Returns an unspecified, abstract "offset" of the passedField
to specify a generic access of the field's value for an instance of its declaring class that can be used with object-based methods likeMemoryAccessor.set_int(Object,long,int)
.long[]
objectFieldOffsets(Class<?> objectClass, Field... fields)
Array alias vor #objectFieldOffset(Class, Field).long[]
objectFieldOffsets(Field... fields)
Array alias vor #objectFieldOffset(Field).int
pageSize()
Returns the system's memory "page size" (whatever that may be exactely for a given system).long
reallocateMemory(long address, long bytes)
void
set_boolean(long address, boolean value)
void
set_boolean(Object instance, long offset, boolean value)
void
set_booleanInBytes(byte[] bytes, int index, boolean value)
void
set_byte(long address, byte value)
void
set_byte(Object instance, long offset, byte value)
void
set_byteInBytes(byte[] bytes, int index, byte value)
void
set_char(long address, char value)
void
set_char(Object instance, long offset, char value)
void
set_charInBytes(byte[] bytes, int index, char value)
void
set_double(long address, double value)
void
set_double(Object instance, long offset, double value)
void
set_doubleInBytes(byte[] bytes, int index, double value)
void
set_float(long address, float value)
void
set_float(Object instance, long offset, float value)
void
set_floatInBytes(byte[] bytes, int index, float value)
void
set_int(long address, int value)
void
set_int(Object instance, long offset, int value)
void
set_intInBytes(byte[] bytes, int index, int value)
void
set_long(long address, long value)
void
set_long(Object instance, long offset, long value)
void
set_longInBytes(byte[] bytes, int index, long value)
void
set_short(long address, short value)
void
set_short(Object instance, long offset, short value)
void
set_shortInBytes(byte[] bytes, int index, short value)
void
setObject(Object instance, long offset, Object value)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface one.microstream.memory.MemoryAccessor
isReversing, objectFieldOffsets, objectFieldOffsets, toReversing
-
Methods inherited from interface one.microstream.memory.MemorySizeProperties
byteSizeFieldValue
-
-
-
-
Method Detail
-
New
public static JdkMemoryAccessor New()
-
guaranteeUsability
public final void guaranteeUsability()
Description copied from interface:MemoryAccessor
Guarantees the full usability of this class by validating if all functionality is usable.- Specified by:
guaranteeUsability
in interfaceMemoryAccessor
-
getDirectByteBufferAddress
public final long getDirectByteBufferAddress(ByteBuffer directBuffer)
- Specified by:
getDirectByteBufferAddress
in interfaceMemoryAccessor
-
deallocateDirectByteBuffer
public final boolean deallocateDirectByteBuffer(ByteBuffer directBuffer)
- Specified by:
deallocateDirectByteBuffer
in interfaceMemoryAccessor
-
isDirectByteBuffer
public final boolean isDirectByteBuffer(ByteBuffer byteBuffer)
- Specified by:
isDirectByteBuffer
in interfaceMemoryAccessor
-
guaranteeDirectByteBuffer
public final ByteBuffer guaranteeDirectByteBuffer(ByteBuffer directBuffer)
- Specified by:
guaranteeDirectByteBuffer
in interfaceMemoryAccessor
-
allocateMemory
public final long allocateMemory(long bytes)
- Specified by:
allocateMemory
in interfaceMemoryAccessor
-
reallocateMemory
public final long reallocateMemory(long address, long bytes)
- Specified by:
reallocateMemory
in interfaceMemoryAccessor
-
freeMemory
public final void freeMemory(long address)
- Specified by:
freeMemory
in interfaceMemoryAccessor
-
fillMemory
public final void fillMemory(long address, long length, byte value)
- Specified by:
fillMemory
in interfaceMemoryAccessor
-
get_byte
public final byte get_byte(long address)
- Specified by:
get_byte
in interfaceMemoryAccessor
-
get_boolean
public final boolean get_boolean(long address)
- Specified by:
get_boolean
in interfaceMemoryAccessor
-
get_short
public final short get_short(long address)
- Specified by:
get_short
in interfaceMemoryAccessor
-
get_char
public final char get_char(long address)
- Specified by:
get_char
in interfaceMemoryAccessor
-
get_int
public final int get_int(long address)
- Specified by:
get_int
in interfaceMemoryAccessor
-
get_float
public final float get_float(long address)
- Specified by:
get_float
in interfaceMemoryAccessor
-
get_long
public final long get_long(long address)
- Specified by:
get_long
in interfaceMemoryAccessor
-
get_double
public final double get_double(long address)
- Specified by:
get_double
in interfaceMemoryAccessor
-
get_byte
public final byte get_byte(Object instance, long offset)
- Specified by:
get_byte
in interfaceMemoryAccessor
-
get_boolean
public final boolean get_boolean(Object instance, long offset)
- Specified by:
get_boolean
in interfaceMemoryAccessor
-
get_short
public final short get_short(Object instance, long offset)
- Specified by:
get_short
in interfaceMemoryAccessor
-
get_char
public final char get_char(Object instance, long offset)
- Specified by:
get_char
in interfaceMemoryAccessor
-
get_int
public final int get_int(Object instance, long offset)
- Specified by:
get_int
in interfaceMemoryAccessor
-
get_float
public final float get_float(Object instance, long offset)
- Specified by:
get_float
in interfaceMemoryAccessor
-
get_long
public final long get_long(Object instance, long offset)
- Specified by:
get_long
in interfaceMemoryAccessor
-
get_double
public final double get_double(Object instance, long offset)
- Specified by:
get_double
in interfaceMemoryAccessor
-
getObject
public final Object getObject(Object instance, long offset)
- Specified by:
getObject
in interfaceMemoryAccessor
-
set_byte
public final void set_byte(long address, byte value)
- Specified by:
set_byte
in interfaceMemoryAccessor
-
set_boolean
public final void set_boolean(long address, boolean value)
- Specified by:
set_boolean
in interfaceMemoryAccessor
-
set_short
public void set_short(long address, short value)
- Specified by:
set_short
in interfaceMemoryAccessor
-
set_char
public final void set_char(long address, char value)
- Specified by:
set_char
in interfaceMemoryAccessor
-
set_int
public final void set_int(long address, int value)
- Specified by:
set_int
in interfaceMemoryAccessor
-
set_float
public final void set_float(long address, float value)
- Specified by:
set_float
in interfaceMemoryAccessor
-
set_long
public final void set_long(long address, long value)
- Specified by:
set_long
in interfaceMemoryAccessor
-
set_double
public final void set_double(long address, double value)
- Specified by:
set_double
in interfaceMemoryAccessor
-
set_byte
public final void set_byte(Object instance, long offset, byte value)
- Specified by:
set_byte
in interfaceMemoryAccessor
-
set_boolean
public final void set_boolean(Object instance, long offset, boolean value)
- Specified by:
set_boolean
in interfaceMemoryAccessor
-
set_short
public final void set_short(Object instance, long offset, short value)
- Specified by:
set_short
in interfaceMemoryAccessor
-
set_char
public final void set_char(Object instance, long offset, char value)
- Specified by:
set_char
in interfaceMemoryAccessor
-
set_int
public final void set_int(Object instance, long offset, int value)
- Specified by:
set_int
in interfaceMemoryAccessor
-
set_float
public final void set_float(Object instance, long offset, float value)
- Specified by:
set_float
in interfaceMemoryAccessor
-
set_long
public final void set_long(Object instance, long offset, long value)
- Specified by:
set_long
in interfaceMemoryAccessor
-
set_double
public final void set_double(Object instance, long offset, double value)
- Specified by:
set_double
in interfaceMemoryAccessor
-
setObject
public final void setObject(Object instance, long offset, Object value)
- Specified by:
setObject
in interfaceMemoryAccessor
-
set_byteInBytes
public final void set_byteInBytes(byte[] bytes, int index, byte value)
- Specified by:
set_byteInBytes
in interfaceMemoryAccessor
-
set_booleanInBytes
public final void set_booleanInBytes(byte[] bytes, int index, boolean value)
- Specified by:
set_booleanInBytes
in interfaceMemoryAccessor
-
set_shortInBytes
public final void set_shortInBytes(byte[] bytes, int index, short value)
- Specified by:
set_shortInBytes
in interfaceMemoryAccessor
-
set_charInBytes
public final void set_charInBytes(byte[] bytes, int index, char value)
- Specified by:
set_charInBytes
in interfaceMemoryAccessor
-
set_intInBytes
public final void set_intInBytes(byte[] bytes, int index, int value)
- Specified by:
set_intInBytes
in interfaceMemoryAccessor
-
set_floatInBytes
public final void set_floatInBytes(byte[] bytes, int index, float value)
- Specified by:
set_floatInBytes
in interfaceMemoryAccessor
-
set_longInBytes
public final void set_longInBytes(byte[] bytes, int index, long value)
- Specified by:
set_longInBytes
in interfaceMemoryAccessor
-
set_doubleInBytes
public final void set_doubleInBytes(byte[] bytes, int index, double value)
- Specified by:
set_doubleInBytes
in interfaceMemoryAccessor
-
copyRange
public final void copyRange(long sourceAddress, long targetAddress, long length)
- Specified by:
copyRange
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, byte[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, boolean[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, short[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, char[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, int[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, float[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, long[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyRangeToArray
public final void copyRangeToArray(long sourceAddress, double[] target)
- Specified by:
copyRangeToArray
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(byte[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(boolean[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(short[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(char[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(int[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(float[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(long[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
copyArrayToAddress
public final void copyArrayToAddress(double[] array, long targetAddress)
- Specified by:
copyArrayToAddress
in interfaceMemoryAccessor
-
asByteArray
public final byte[] asByteArray(long[] values)
- Specified by:
asByteArray
in interfaceMemoryAccessor
-
asByteArray
public final byte[] asByteArray(long value)
- Specified by:
asByteArray
in interfaceMemoryAccessor
-
objectFieldOffset
public final long objectFieldOffset(Field field)
Description copied from interface:MemoryAccessor
Returns an unspecified, abstract "offset" of the passedField
to specify a generic access of the field's value for an instance of its declaring class that can be used with object-based methods likeMemoryAccessor.set_int(Object,long,int)
. Whether that offset is an actual low-level memory offset relative to an instance' field offset base or simply an index of the passed field in its declaring class' list of fields, is implementation-specific.- Specified by:
objectFieldOffset
in interfaceMemoryAccessor
- Parameters:
field
- theField
whose abstract offset shall be determined.- Returns:
- the passed
Field
's abstract offset.
-
objectFieldOffsets
public final long[] objectFieldOffsets(Field... fields)
Description copied from interface:MemoryAccessor
Array alias vor #objectFieldOffset(Field).- Specified by:
objectFieldOffsets
in interfaceMemoryAccessor
-
objectFieldOffset
public final long objectFieldOffset(Class<?> objectClass, Field field)
Description copied from interface:MemoryAccessor
Similar toMemoryAccessor.objectFieldOffset(Field)
, but with the specific object class.
The difference is that the actual object's class is not the declaring class of its fields if it only extends another class but does not declare an object field itself.- Specified by:
objectFieldOffset
in interfaceMemoryAccessor
- Returns:
-
objectFieldOffsets
public final long[] objectFieldOffsets(Class<?> objectClass, Field... fields)
Description copied from interface:MemoryAccessor
Array alias vor #objectFieldOffset(Class, Field).- Specified by:
objectFieldOffsets
in interfaceMemoryAccessor
-
ensureClassInitialized
public final void ensureClassInitialized(Class<?> c)
- Specified by:
ensureClassInitialized
in interfaceMemoryAccessor
-
ensureClassInitialized
public final void ensureClassInitialized(Class<?> c, Iterable<Field> usedFields)
Description copied from interface:MemoryAccessor
Uses the passed fields if required by the implementation. If not, this method behaves exactely likeMemoryAccessor.ensureClassInitialized(Class)
.- Specified by:
ensureClassInitialized
in interfaceMemoryAccessor
-
instantiateBlank
public final <T> T instantiateBlank(Class<T> c) throws InstantiationRuntimeException
- Specified by:
instantiateBlank
in interfaceMemoryAccessor
- Throws:
InstantiationRuntimeException
-
pageSize
public final int pageSize()
Description copied from interface:MemorySizeProperties
Returns the system's memory "page size" (whatever that may be exactely for a given system). Use with care (and the dependency to a system value in mind!).- Specified by:
pageSize
in interfaceMemorySizeProperties
- Returns:
- the system's memory "page size".
-
byteSizeReference
public final int byteSizeReference()
- Specified by:
byteSizeReference
in interfaceMemorySizeProperties
-
byteSizeInstance
public final int byteSizeInstance(Class<?> type)
- Specified by:
byteSizeInstance
in interfaceMemorySizeProperties
-
byteSizeObjectHeader
public final int byteSizeObjectHeader(Class<?> type)
- Specified by:
byteSizeObjectHeader
in interfaceMemorySizeProperties
-
byteSizeFieldValue
public final int byteSizeFieldValue(Class<?> type)
- Specified by:
byteSizeFieldValue
in interfaceMemorySizeProperties
-
byteSizeArray_byte
public final long byteSizeArray_byte(long elementCount)
- Specified by:
byteSizeArray_byte
in interfaceMemorySizeProperties
-
byteSizeArray_boolean
public final long byteSizeArray_boolean(long elementCount)
- Specified by:
byteSizeArray_boolean
in interfaceMemorySizeProperties
-
byteSizeArray_short
public final long byteSizeArray_short(long elementCount)
- Specified by:
byteSizeArray_short
in interfaceMemorySizeProperties
-
byteSizeArray_char
public final long byteSizeArray_char(long elementCount)
- Specified by:
byteSizeArray_char
in interfaceMemorySizeProperties
-
byteSizeArray_int
public final long byteSizeArray_int(long elementCount)
- Specified by:
byteSizeArray_int
in interfaceMemorySizeProperties
-
byteSizeArray_float
public final long byteSizeArray_float(long elementCount)
- Specified by:
byteSizeArray_float
in interfaceMemorySizeProperties
-
byteSizeArray_long
public final long byteSizeArray_long(long elementCount)
- Specified by:
byteSizeArray_long
in interfaceMemorySizeProperties
-
byteSizeArray_double
public final long byteSizeArray_double(long elementCount)
- Specified by:
byteSizeArray_double
in interfaceMemorySizeProperties
-
byteSizeArrayObject
public final long byteSizeArrayObject(long elementCount)
- Specified by:
byteSizeArrayObject
in interfaceMemorySizeProperties
-
-