Class Binary
- java.lang.Object
-
- one.microstream.persistence.binary.types.Binary
-
- All Implemented Interfaces:
Chunk
- Direct Known Subclasses:
BinaryLoadItem,ChunksBuffer,ChunksWrapper
public abstract class Binary extends Object implements Chunk
-
-
Constructor Summary
Constructors Constructor Description Binary()
-
Method Summary
Modifier and Type Method Description longbinaryListElementsAddress(long binaryListOffset)static longbinaryListMaximumLength()static longbinaryListMinimumLength()abstract ByteBuffer[]buffers()byte[]buildArray_byte()char[]buildArray_char()char[]buildArray_char(long listOffset)BooleanbuildBoolean()BytebuildByte()CharacterbuildCharacter()DoublebuildDouble()FloatbuildFloat()IntegerbuildInteger()LongbuildLong()ShortbuildShort()StringbuildString()longbuildStrings(long stringsListOffset, String[] target)static longcalculateBinaryLengthChars(long count)static longcalculateReferenceListTotalBinaryLength(long count)static longcalculateStringListContentBinaryLength(String[] strings)abstract BinarychannelChunk(int channelIndex)abstract intchannelCount()voidcollectElementsIntoArray(long binaryOffset, PersistenceObjectIdResolver oidResolver, Object[] target)intcollectKeyValueReferences(long binaryOffset, int length, PersistenceObjectIdResolver oidResolver, BiConsumer<Object,Object> collector)intcollectListObjectReferences(long binaryOffset, PersistenceObjectIdResolver oidResolver, Consumer<Object> collector)voidcollectObjectReferences(long binaryOffset, int length, PersistenceObjectIdResolver oidResolver, Consumer<Object> collector)boolean[]createArray_boolean()byte[]createArray_byte()char[]createArray_char()char[]createArray_char(long listOffset)double[]createArray_double()float[]createArray_float()int[]createArray_int()long[]createArray_long()short[]createArray_short()static longentityAddressFromContentAddress(long entityContentAddress)static longentityContentAddress(long entityAddress)static longentityContentLength(long entityTotalLength)static intentityHeaderLength()static longentityTotalLength(long entityContentLength)booleanget_boolean(long offset)byteget_byte(long offset)charget_char(long offset)doubleget_double(long offset)floatget_float(long offset)intget_int(long offset)longget_long(long offset)shortget_short(long offset)static longgetBinaryListElementCountRawValue(long binaryListAddress)longgetBinaryListElementCountUnvalidating(long listOffset)longgetBinaryListElementCountValidating(long listOffset, long elementLength)longgetBinaryListTotalByteLength(long listOffset)static longgetBinaryListTotalByteLengthRawValue(long binaryListAddress)longgetBuildItemContentLength()longgetBuildItemObjectId()longgetBuildItemTypeId()longgetEntityBoundAddress()longgetEntityLength()static longgetEntityLengthRawValue(long entityAddress)longgetEntityObjectId()static longgetEntityObjectIdRawValue(long entityAddress)longgetEntityTypeId()static longgetEntityTypeIdRawValue(long entityAddress)ObjectgetHelper(Object key)Helper instances can be used as temporary additional state for the duration of the building process.longgetListElementCount(long listStartOffset, int elementLength)longgetListElementCountKeyValue(long listStartOffset)longgetListElementCountReferences(long listStartOffset)longgetLoadItemAvailableContentLength()intgetSizedArrayElementCount(long headerOffset)longgetSizedArrayElementsAddress(long headerOffset)intgetSizedArrayLength(long sizedArrayOffset)booleanisSwitchedByteOrder()static booleanisValidEntityLength(long entityLength)static booleanisValidGapLength(long gapLength)abstract voiditerateChannelChunks(Consumer<? super Binary> logic)abstract voiditerateEntityData(BinaryEntityDataReader reader)voiditerateKeyValueEntriesReferences(long listOffset, PersistenceObjectIdAcceptor iterator)voiditerateListElementReferences(long listOffset, PersistenceObjectIdAcceptor iterator)voiditerateListStructureReferenceRange(long listOffset, int referencesPerElement, PersistenceObjectIdAcceptor iterator)voiditerateReferenceRange(long startOffset, long boundOffset, PersistenceObjectIdAcceptor iterator)voiditerateReferenceRangeUnvalidated(long startOffset, long boundOffset, PersistenceObjectIdAcceptor iterator)voiditerateSizedArrayElementReferences(long offset, PersistenceObjectIdAcceptor iterator)static longkeyValueBinaryLength()static longkeyValueReferenceCount(long elementCount)static intlengthLength()abstract longloadItemEntityAddress()abstract longloadItemEntityContentAddress()abstract voidmodifyLoadItem(long entityContentAddress, long entityTotalLength, long entityTypeId, long entityObjectId)static intobjectIdByteLength()voidread_bytes(long address, byte[] target)voidread_longs(long address, long[] target)voidreadCharsDirect(long address, char[] chars, int offset, int length)static longreferenceBinaryLength(long referenceCount)voidregisterHelper(Object key, Object helper)Helper instances can be used as temporary additional state for the duration of the building process.voidstore_boolean(long address, boolean value)voidstore_byte(long address, byte value)voidstore_char(long address, char value)voidstore_double(long address, double value)voidstore_float(long address, float value)voidstore_int(long address, int value)voidstore_long(long address, long value)voidstore_short(long address, short value)voidstoreArray_boolean(long typeId, long objectId, boolean[] array)voidstoreArray_byte(long typeId, long objectId, byte[] array)voidstoreArray_char(long typeId, long objectId, char[] array)voidstoreArray_double(long typeId, long objectId, double[] array)voidstoreArray_float(long typeId, long objectId, float[] array)voidstoreArray_int(long typeId, long objectId, int[] array)voidstoreArray_long(long typeId, long objectId, long[] array)voidstoreArray_short(long typeId, long objectId, short[] array)voidstoreBoolean(long typeId, long objectId, boolean value)voidstoreByte(long typeId, long objectId, byte value)voidstoreCharacter(long typeId, long objectId, char value)longstoreCharsAsList(long storeAddress, char[] chars)longstoreCharsAsList(long storeAddress, char[] chars, int offset, int length)voidstoreCharsDirect(long address, char[] chars, int offset, int length)voidstoreDouble(long typeId, long objectId, double value)abstract longstoreEntityHeader(long entityContentLength, long entityTypeId, long entityObjectId)Writes the header (etc...).voidstoreFixedSize(PersistenceStoreHandler handler, long contentLength, long typeId, long objectId, Object instance, long[] memoryOffsets, BinaryValueStorer[] storers)voidstoreFloat(long typeId, long objectId, float value)voidstoreInteger(long typeId, long objectId, int value)longstoreIterableAsList(long tid, long oid, long headerOffset, Iterable<?> elements, long size, PersistenceFunction persister)voidstoreIterableContentAsList(long storeAddress, PersistenceFunction persister, Iterable<?> elements, long elementCount)longstoreKeyValuesAsEntries(long typeId, long objectId, long headerOffset, Iterable<? extends KeyValue<?,?>> keyValues, long size, PersistenceFunction persister)voidstoreKeyValuesAsEntries(long storeAddress, PersistenceFunction persister, Iterable<? extends KeyValue<?,?>> elements, long elementCount)longstoreListHeader(long storeAddress, long elementsBinaryLength, long elementsCount)voidstoreLong(long typeId, long objectId, long value)<K,V>
longstoreMapEntrySet(long typeId, long objectId, long headerOffset, Set<Map.Entry<K,V>> entrySet, PersistenceFunction persister)longstoreReferences(long typeId, long objectId, long binaryOffset, PersistenceStoreHandler idResolver, Object[] array)longstoreReferences(long typeId, long objectId, long binaryOffset, PersistenceStoreHandler idResolver, Object[] array, int arrayOffset, int arrayLength)voidstoreRoots(long typeId, long objectId, XGettingTable<String,Object> entries, PersistenceStoreHandler idResolver)voidstoreShort(long typeId, long objectId, short value)longstoreSizedArray(long tid, long oid, long headerOffset, Object[] array, int offset, int size, PersistenceStoreHandler persister)longstoreSizedArray(long tid, long oid, long headerOffset, Object[] array, int size, PersistenceStoreHandler persister)voidstoreStateless(long typeId, long objectId)voidstoreStringsAsList(long storeAddress, long precalculatedContentBinaryLength, String[] strings)voidstoreStringsAsList(long storeAddress, long precalculatedContentBinaryLength, String[] strings, int offset, int length)voidstoreStringValue(long typeId, long objectId, char[] chars)voidstoreStringValue(long typeId, long objectId, char[] chars, int offset, int length)voidstoreStringValue(long typeId, long objectId, String string)static longtoBinaryListContentByteLength(long binaryListTotalByteLength)static longtoBinaryListElementsAddress(long binaryListAddress)static longtoBinaryListTotalByteLength(long binaryListElementsByteLength)voidupdateArray_boolean(boolean[] array)voidupdateArray_byte(byte[] array)voidupdateArray_char(char[] array)voidupdateArray_double(double[] array)voidupdateArray_float(float[] array)voidupdateArray_int(int[] array)voidupdateArray_long(long[] array)voidupdateArray_short(short[] array)voidupdateArrayObjectReferences(long binaryOffset, PersistenceObjectIdResolver oidResolver, Object[] array, int arrayOffset, int arrayLength)voidupdateFixedSize(Object instance, BinaryValueSetter[] setters, long[] memoryOffsets, PersistenceObjectIdResolver idResolver)intupdateSizedArrayObjectReferences(long headerOffset, Object[] array, PersistenceObjectIdResolver idResolver)Updates the passed array up to the size defined by the binary data, returns the size.voidvalidateArrayLength(Object[] array, long headerOffset)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface one.microstream.persistence.binary.types.Chunk
clear, isEmpty, totalLength
-
-
-
-
Method Detail
-
keyValueReferenceCount
public static final long keyValueReferenceCount(long elementCount)
-
keyValueBinaryLength
public static final long keyValueBinaryLength()
-
binaryListMinimumLength
public static final long binaryListMinimumLength()
-
binaryListMaximumLength
public static final long binaryListMaximumLength()
-
toBinaryListTotalByteLength
public static final long toBinaryListTotalByteLength(long binaryListElementsByteLength)
-
toBinaryListContentByteLength
public static final long toBinaryListContentByteLength(long binaryListTotalByteLength)
-
lengthLength
public static final int lengthLength()
- Returns:
- the length in bytes of a peristent item's length field (8 bytes).
-
isValidGapLength
public static final boolean isValidGapLength(long gapLength)
-
isValidEntityLength
public static final boolean isValidEntityLength(long entityLength)
-
entityHeaderLength
public static final int entityHeaderLength()
-
entityTotalLength
public static final long entityTotalLength(long entityContentLength)
-
entityContentLength
public static final long entityContentLength(long entityTotalLength)
-
isSwitchedByteOrder
public boolean isSwitchedByteOrder()
-
getEntityLength
public final long getEntityLength()
-
getEntityTypeId
public final long getEntityTypeId()
-
getEntityObjectId
public final long getEntityObjectId()
-
getEntityBoundAddress
public final long getEntityBoundAddress()
-
getEntityLengthRawValue
public static final long getEntityLengthRawValue(long entityAddress)
-
getEntityTypeIdRawValue
public static final long getEntityTypeIdRawValue(long entityAddress)
-
getEntityObjectIdRawValue
public static final long getEntityObjectIdRawValue(long entityAddress)
-
entityContentAddress
public static final long entityContentAddress(long entityAddress)
-
objectIdByteLength
public static final int objectIdByteLength()
-
entityAddressFromContentAddress
public static final long entityAddressFromContentAddress(long entityContentAddress)
-
getBuildItemContentLength
public final long getBuildItemContentLength()
-
getBuildItemTypeId
public final long getBuildItemTypeId()
-
getBuildItemObjectId
public final long getBuildItemObjectId()
-
referenceBinaryLength
public static final long referenceBinaryLength(long referenceCount)
-
storeEntityHeader
public abstract long storeEntityHeader(long entityContentLength, long entityTypeId, long entityObjectId)Writes the header (etc...).Returns a memory address that is guaranteed to be safe for writing len bytes. Writing any more bytes will lead to unpredictable results, from (most likely) destroying the byte stream's consistency up to crashing the VM immediately or at some point in the future.
DO NOT WRITE MORE THEN len BYTES TO THE RETURNED ADDRESS!
- Parameters:
entityContentLength-entityTypeId-entityObjectId-
-
getListElementCountKeyValue
public final long getListElementCountKeyValue(long listStartOffset)
-
loadItemEntityContentAddress
public abstract long loadItemEntityContentAddress()
-
loadItemEntityAddress
public abstract long loadItemEntityAddress()
-
modifyLoadItem
public abstract void modifyLoadItem(long entityContentAddress, long entityTotalLength, long entityTypeId, long entityObjectId)
-
get_byte
public final byte get_byte(long offset)
-
get_boolean
public final boolean get_boolean(long offset)
-
get_short
public final short get_short(long offset)
-
get_char
public final char get_char(long offset)
-
get_int
public final int get_int(long offset)
-
get_float
public final float get_float(long offset)
-
get_long
public final long get_long(long offset)
-
get_double
public final double get_double(long offset)
-
channelChunk
public abstract Binary channelChunk(int channelIndex)
-
channelCount
public abstract int channelCount()
-
iterateEntityData
public abstract void iterateEntityData(BinaryEntityDataReader reader)
-
storeKeyValuesAsEntries
public final long storeKeyValuesAsEntries(long typeId, long objectId, long headerOffset, Iterable<? extends KeyValue<?,?>> keyValues, long size, PersistenceFunction persister)
-
storeMapEntrySet
public final <K,V> long storeMapEntrySet(long typeId, long objectId, long headerOffset, Set<Map.Entry<K,V>> entrySet, PersistenceFunction persister)
-
storeSizedArray
public final long storeSizedArray(long tid, long oid, long headerOffset, Object[] array, int size, PersistenceStoreHandler persister)
-
storeSizedArray
public final long storeSizedArray(long tid, long oid, long headerOffset, Object[] array, int offset, int size, PersistenceStoreHandler persister)
-
storeRoots
public final void storeRoots(long typeId, long objectId, XGettingTable<String,Object> entries, PersistenceStoreHandler idResolver)
-
storeIterableAsList
public final long storeIterableAsList(long tid, long oid, long headerOffset, Iterable<?> elements, long size, PersistenceFunction persister)
-
getSizedArrayElementCount
public int getSizedArrayElementCount(long headerOffset)
-
updateSizedArrayObjectReferences
public final int updateSizedArrayObjectReferences(long headerOffset, Object[] array, PersistenceObjectIdResolver idResolver)Updates the passed array up to the size defined by the binary data, returns the size.
-
getSizedArrayLength
public final int getSizedArrayLength(long sizedArrayOffset)
-
getSizedArrayElementsAddress
public final long getSizedArrayElementsAddress(long headerOffset)
-
validateArrayLength
public final void validateArrayLength(Object[] array, long headerOffset)
-
getBinaryListTotalByteLength
public final long getBinaryListTotalByteLength(long listOffset)
-
getBinaryListTotalByteLengthRawValue
public static final long getBinaryListTotalByteLengthRawValue(long binaryListAddress)
-
getLoadItemAvailableContentLength
public final long getLoadItemAvailableContentLength()
-
getBinaryListElementCountValidating
public final long getBinaryListElementCountValidating(long listOffset, long elementLength)
-
getBinaryListElementCountUnvalidating
public final long getBinaryListElementCountUnvalidating(long listOffset)
-
getBinaryListElementCountRawValue
public static final long getBinaryListElementCountRawValue(long binaryListAddress)
-
toBinaryListElementsAddress
public static final long toBinaryListElementsAddress(long binaryListAddress)
-
binaryListElementsAddress
public final long binaryListElementsAddress(long binaryListOffset)
-
getListElementCount
public final long getListElementCount(long listStartOffset, int elementLength)
-
getListElementCountReferences
public final long getListElementCountReferences(long listStartOffset)
-
calculateReferenceListTotalBinaryLength
public static final long calculateReferenceListTotalBinaryLength(long count)
-
calculateStringListContentBinaryLength
public static final long calculateStringListContentBinaryLength(String[] strings)
-
calculateBinaryLengthChars
public static final long calculateBinaryLengthChars(long count)
-
iterateListElementReferences
public final void iterateListElementReferences(long listOffset, PersistenceObjectIdAcceptor iterator)
-
iterateSizedArrayElementReferences
public final void iterateSizedArrayElementReferences(long offset, PersistenceObjectIdAcceptor iterator)
-
iterateListStructureReferenceRange
public final void iterateListStructureReferenceRange(long listOffset, int referencesPerElement, PersistenceObjectIdAcceptor iterator)
-
iterateKeyValueEntriesReferences
public final void iterateKeyValueEntriesReferences(long listOffset, PersistenceObjectIdAcceptor iterator)
-
iterateReferenceRange
public final void iterateReferenceRange(long startOffset, long boundOffset, PersistenceObjectIdAcceptor iterator)
-
iterateReferenceRangeUnvalidated
public final void iterateReferenceRangeUnvalidated(long startOffset, long boundOffset, PersistenceObjectIdAcceptor iterator)
-
storeArray_byte
public final void storeArray_byte(long typeId, long objectId, byte[] array)
-
storeArray_boolean
public final void storeArray_boolean(long typeId, long objectId, boolean[] array)
-
storeArray_short
public final void storeArray_short(long typeId, long objectId, short[] array)
-
storeArray_char
public final void storeArray_char(long typeId, long objectId, char[] array)
-
storeArray_int
public final void storeArray_int(long typeId, long objectId, int[] array)
-
storeArray_float
public final void storeArray_float(long typeId, long objectId, float[] array)
-
storeArray_long
public final void storeArray_long(long typeId, long objectId, long[] array)
-
storeArray_double
public final void storeArray_double(long typeId, long objectId, double[] array)
-
storeByte
public final void storeByte(long typeId, long objectId, byte value)
-
storeBoolean
public final void storeBoolean(long typeId, long objectId, boolean value)
-
storeShort
public final void storeShort(long typeId, long objectId, short value)
-
storeCharacter
public final void storeCharacter(long typeId, long objectId, char value)
-
storeInteger
public final void storeInteger(long typeId, long objectId, int value)
-
storeFloat
public final void storeFloat(long typeId, long objectId, float value)
-
storeLong
public final void storeLong(long typeId, long objectId, long value)
-
storeDouble
public final void storeDouble(long typeId, long objectId, double value)
-
storeStateless
public final void storeStateless(long typeId, long objectId)
-
storeStringValue
public final void storeStringValue(long typeId, long objectId, String string)
-
storeStringValue
public final void storeStringValue(long typeId, long objectId, char[] chars)
-
storeStringValue
public final void storeStringValue(long typeId, long objectId, char[] chars, int offset, int length)
-
storeReferences
public final long storeReferences(long typeId, long objectId, long binaryOffset, PersistenceStoreHandler idResolver, Object[] array)
-
storeReferences
public final long storeReferences(long typeId, long objectId, long binaryOffset, PersistenceStoreHandler idResolver, Object[] array, int arrayOffset, int arrayLength)
-
storeListHeader
public final long storeListHeader(long storeAddress, long elementsBinaryLength, long elementsCount)
-
storeIterableContentAsList
public final void storeIterableContentAsList(long storeAddress, PersistenceFunction persister, Iterable<?> elements, long elementCount)
-
storeKeyValuesAsEntries
public final void storeKeyValuesAsEntries(long storeAddress, PersistenceFunction persister, Iterable<? extends KeyValue<?,?>> elements, long elementCount)
-
storeStringsAsList
public final void storeStringsAsList(long storeAddress, long precalculatedContentBinaryLength, String[] strings)
-
storeStringsAsList
public final void storeStringsAsList(long storeAddress, long precalculatedContentBinaryLength, String[] strings, int offset, int length)
-
storeCharsAsList
public final long storeCharsAsList(long storeAddress, char[] chars)
-
storeCharsAsList
public final long storeCharsAsList(long storeAddress, char[] chars, int offset, int length)
-
storeCharsDirect
public final void storeCharsDirect(long address, char[] chars, int offset, int length)
-
readCharsDirect
public final void readCharsDirect(long address, char[] chars, int offset, int length)
-
storeFixedSize
public final void storeFixedSize(PersistenceStoreHandler handler, long contentLength, long typeId, long objectId, Object instance, long[] memoryOffsets, BinaryValueStorer[] storers)
-
buildStrings
public final long buildStrings(long stringsListOffset, String[] target)
-
buildByte
public final Byte buildByte()
-
buildBoolean
public final Boolean buildBoolean()
-
buildShort
public final Short buildShort()
-
buildCharacter
public final Character buildCharacter()
-
buildInteger
public final Integer buildInteger()
-
buildFloat
public final Float buildFloat()
-
buildLong
public final Long buildLong()
-
buildDouble
public final Double buildDouble()
-
buildArray_byte
public final byte[] buildArray_byte()
-
createArray_byte
public final byte[] createArray_byte()
-
updateArray_byte
public final void updateArray_byte(byte[] array)
-
createArray_boolean
public final boolean[] createArray_boolean()
-
updateArray_boolean
public final void updateArray_boolean(boolean[] array)
-
createArray_short
public final short[] createArray_short()
-
updateArray_short
public final void updateArray_short(short[] array)
-
createArray_char
public final char[] createArray_char()
-
createArray_char
public final char[] createArray_char(long listOffset)
-
updateArray_char
public final void updateArray_char(char[] array)
-
buildString
public final String buildString()
-
buildArray_char
public final char[] buildArray_char()
-
buildArray_char
public final char[] buildArray_char(long listOffset)
-
createArray_int
public final int[] createArray_int()
-
updateArray_int
public final void updateArray_int(int[] array)
-
createArray_float
public final float[] createArray_float()
-
updateArray_float
public final void updateArray_float(float[] array)
-
createArray_long
public final long[] createArray_long()
-
updateArray_long
public final void updateArray_long(long[] array)
-
createArray_double
public final double[] createArray_double()
-
updateArray_double
public final void updateArray_double(double[] array)
-
updateArrayObjectReferences
public final void updateArrayObjectReferences(long binaryOffset, PersistenceObjectIdResolver oidResolver, Object[] array, int arrayOffset, int arrayLength)
-
collectElementsIntoArray
public final void collectElementsIntoArray(long binaryOffset, PersistenceObjectIdResolver oidResolver, Object[] target)
-
collectListObjectReferences
public final int collectListObjectReferences(long binaryOffset, PersistenceObjectIdResolver oidResolver, Consumer<Object> collector)
-
collectObjectReferences
public final void collectObjectReferences(long binaryOffset, int length, PersistenceObjectIdResolver oidResolver, Consumer<Object> collector)
-
collectKeyValueReferences
public final int collectKeyValueReferences(long binaryOffset, int length, PersistenceObjectIdResolver oidResolver, BiConsumer<Object,Object> collector)
-
updateFixedSize
public final void updateFixedSize(Object instance, BinaryValueSetter[] setters, long[] memoryOffsets, PersistenceObjectIdResolver idResolver)
-
store_byte
public final void store_byte(long address, byte value)
-
store_boolean
public final void store_boolean(long address, boolean value)
-
store_short
public void store_short(long address, short value)
-
store_char
public void store_char(long address, char value)
-
store_int
public void store_int(long address, int value)
-
store_float
public void store_float(long address, float value)
-
store_long
public void store_long(long address, long value)
-
store_double
public void store_double(long address, double value)
-
read_bytes
public final void read_bytes(long address, byte[] target)
-
read_longs
public void read_longs(long address, long[] target)
-
buffers
public abstract ByteBuffer[] buffers()
-
registerHelper
public final void registerHelper(Object key, Object helper)
Helper instances can be used as temporary additional state for the duration of the building process. E.g.: JDK hash collections cannot properly collect elements during the building process as the element instances might still be in an initialized state without their proper data, so hashing and equality comparisons would fail or result in all elements being "equal". So building JDK hash collections required to pre-collect their elements in an additional helper structure and defer the actual elements collecting to the completion.Similar problems with other or complex custom handlers are conceivable.
Only one helper object can be registered per subject instance (the instance to be built).
-
getHelper
public final Object getHelper(Object key)
Helper instances can be used as temporary additional state for the duration of the building process. E.g.: JDK hash collections cannot properly collect elements during the building process as the element instances might still be in an initialized state without their proper data, so hashing and equality comparisons would failt or result in all elements being "equal". So building JDK hash collections required to pre-collect their elements in an additional helper structure and defer the actual elements collecting to the completion.Similar problems with other or complex custom handlers are conceivable.
-
-