Package org.apache.druid.segment.data
Class SafeWritableMemory
java.lang.Object
org.apache.druid.segment.data.SafeWritableBase
org.apache.druid.segment.data.SafeWritableMemory
- All Implemented Interfaces:
org.apache.datasketches.memory.BaseState,org.apache.datasketches.memory.Memory,org.apache.datasketches.memory.WritableMemory
public class SafeWritableMemory
extends SafeWritableBase
implements org.apache.datasketches.memory.WritableMemory
Safety first! Don't trust something whose contents you locations to read and write stuff to, but need a
Memory or WritableMemory? use this!
Delegates everything to an underlying ByteBuffer so all read and write operations will have bounds checks
built in rather than using 'unsafe'.
-
Field Summary
Fields inherited from interface org.apache.datasketches.memory.BaseState
defaultMemReqSvr -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.datasketches.memory.Bufferorg.apache.datasketches.memory.WritableBufferasWritableBuffer(ByteOrder byteOrder) voidclear()voidclear(long offsetBytes, long lengthBytes) voidclearBits(long offsetBytes, byte bitMask) booleancompareAndSwapLong(long offsetBytes, long expect, long update) intcompareTo(long thisOffsetBytes, long thisLengthBytes, org.apache.datasketches.memory.Memory that, long thatOffsetBytes, long thatLengthBytes) voidcopyTo(long srcOffsetBytes, org.apache.datasketches.memory.WritableMemory destination, long dstOffsetBytes, long lengthBytes) booleanvoidfill(byte value) voidfill(long offsetBytes, long lengthBytes, byte value) longgetAndAddLong(long offsetBytes, long delta) longgetAndSetLong(long offsetBytes, long newValue) getArray()voidgetBooleanArray(long offsetBytes, boolean[] dstArray, int dstOffsetBooleans, int lengthBooleans) voidgetByteArray(long offsetBytes, byte[] dstArray, int dstOffsetBytes, int lengthBytes) voidgetCharArray(long offsetBytes, char[] dstArray, int dstOffsetChars, int lengthChars) intgetCharsFromUtf8(long offsetBytes, int utf8LengthBytes, Appendable dst) intgetCharsFromUtf8(long offsetBytes, int utf8LengthBytes, StringBuilder dst) voidgetDoubleArray(long offsetBytes, double[] dstArray, int dstOffsetDoubles, int lengthDoubles) voidgetFloatArray(long offsetBytes, float[] dstArray, int dstOffsetFloats, int lengthFloats) voidgetIntArray(long offsetBytes, int[] dstArray, int dstOffsetInts, int lengthInts) voidgetLongArray(long offsetBytes, long[] dstArray, int dstOffsetLongs, int lengthLongs) voidgetShortArray(long offsetBytes, short[] dstArray, int dstOffsetShorts, int lengthShorts) voidputBooleanArray(long offsetBytes, boolean[] srcArray, int srcOffsetBooleans, int lengthBooleans) voidputByteArray(long offsetBytes, byte[] srcArray, int srcOffsetBytes, int lengthBytes) voidputCharArray(long offsetBytes, char[] srcArray, int srcOffsetChars, int lengthChars) longputCharsToUtf8(long offsetBytes, CharSequence src) voidputDoubleArray(long offsetBytes, double[] srcArray, int srcOffsetDoubles, int lengthDoubles) voidputFloatArray(long offsetBytes, float[] srcArray, int srcOffsetFloats, int lengthFloats) voidputIntArray(long offsetBytes, int[] srcArray, int srcOffsetInts, int lengthInts) voidputLongArray(long offsetBytes, long[] srcArray, int srcOffsetLongs, int lengthLongs) voidputShortArray(long offsetBytes, short[] srcArray, int srcOffsetShorts, int lengthShorts) org.apache.datasketches.memory.MemoryvoidsetBits(long offsetBytes, byte bitMask) static SafeWritableMemorywrap(byte[] bytes) static SafeWritableMemorywrap(ByteBuffer buffer) static SafeWritableMemorywrap(ByteBuffer buffer, int offset, int size) static SafeWritableMemorywrap(ByteBuffer buffer, ByteOrder byteOrder) org.apache.datasketches.memory.WritableMemorywritableRegion(long offsetBytes, long capacityBytes, ByteOrder byteOrder) voidwriteTo(long offsetBytes, long lengthBytes, WritableByteChannel out) Methods inherited from class org.apache.druid.segment.data.SafeWritableBase
checkValidAndBounds, getBoolean, getByte, getByteBuffer, getCapacity, getChar, getCumulativeOffset, getCumulativeOffset, getDouble, getFloat, getInt, getLong, getMemoryRequestServer, getRegionOffset, getRegionOffset, getShort, getTypeByteOrder, hasArray, hasByteBuffer, isByteOrderCompatible, isDirect, isReadOnly, isSameResource, isValid, putBoolean, putByte, putChar, putDouble, putFloat, putInt, putLong, putShort, toHexString, xxHash64, xxHash64Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.datasketches.memory.BaseState
checkValidAndBounds, equals, getByteBuffer, getCapacity, getCumulativeOffset, getCumulativeOffset, getRegionOffset, getRegionOffset, getTypeByteOrder, hasArray, hasByteBuffer, hashCode, isByteOrderCompatible, isDirect, isReadOnly, isSameResource, isValid, toHexString, xxHash64, xxHash64Methods inherited from interface org.apache.datasketches.memory.Memory
asBuffer, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getShort, regionMethods inherited from interface org.apache.datasketches.memory.WritableMemory
asWritableBuffer, getMemoryRequestServer, putBoolean, putByte, putChar, putDouble, putFloat, putInt, putLong, putShort, writableRegion
-
Constructor Details
-
SafeWritableMemory
-
-
Method Details
-
wrap
-
wrap
-
wrap
-
wrap
-
region
public org.apache.datasketches.memory.Memory region(long offsetBytes, long capacityBytes, ByteOrder byteOrder) - Specified by:
regionin interfaceorg.apache.datasketches.memory.Memory
-
asBuffer
- Specified by:
asBufferin interfaceorg.apache.datasketches.memory.Memory
-
getBooleanArray
public void getBooleanArray(long offsetBytes, boolean[] dstArray, int dstOffsetBooleans, int lengthBooleans) - Specified by:
getBooleanArrayin interfaceorg.apache.datasketches.memory.Memory
-
getByteArray
public void getByteArray(long offsetBytes, byte[] dstArray, int dstOffsetBytes, int lengthBytes) - Specified by:
getByteArrayin interfaceorg.apache.datasketches.memory.Memory
-
getCharArray
public void getCharArray(long offsetBytes, char[] dstArray, int dstOffsetChars, int lengthChars) - Specified by:
getCharArrayin interfaceorg.apache.datasketches.memory.Memory
-
getCharsFromUtf8
public int getCharsFromUtf8(long offsetBytes, int utf8LengthBytes, Appendable dst) throws IOException, org.apache.datasketches.memory.Utf8CodingException - Specified by:
getCharsFromUtf8in interfaceorg.apache.datasketches.memory.Memory- Throws:
IOExceptionorg.apache.datasketches.memory.Utf8CodingException
-
getCharsFromUtf8
public int getCharsFromUtf8(long offsetBytes, int utf8LengthBytes, StringBuilder dst) throws org.apache.datasketches.memory.Utf8CodingException - Specified by:
getCharsFromUtf8in interfaceorg.apache.datasketches.memory.Memory- Throws:
org.apache.datasketches.memory.Utf8CodingException
-
getDoubleArray
public void getDoubleArray(long offsetBytes, double[] dstArray, int dstOffsetDoubles, int lengthDoubles) - Specified by:
getDoubleArrayin interfaceorg.apache.datasketches.memory.Memory
-
getFloatArray
public void getFloatArray(long offsetBytes, float[] dstArray, int dstOffsetFloats, int lengthFloats) - Specified by:
getFloatArrayin interfaceorg.apache.datasketches.memory.Memory
-
getIntArray
public void getIntArray(long offsetBytes, int[] dstArray, int dstOffsetInts, int lengthInts) - Specified by:
getIntArrayin interfaceorg.apache.datasketches.memory.Memory
-
getLongArray
public void getLongArray(long offsetBytes, long[] dstArray, int dstOffsetLongs, int lengthLongs) - Specified by:
getLongArrayin interfaceorg.apache.datasketches.memory.Memory
-
getShortArray
public void getShortArray(long offsetBytes, short[] dstArray, int dstOffsetShorts, int lengthShorts) - Specified by:
getShortArrayin interfaceorg.apache.datasketches.memory.Memory
-
compareTo
public int compareTo(long thisOffsetBytes, long thisLengthBytes, org.apache.datasketches.memory.Memory that, long thatOffsetBytes, long thatLengthBytes) - Specified by:
compareToin interfaceorg.apache.datasketches.memory.Memory
-
copyTo
public void copyTo(long srcOffsetBytes, org.apache.datasketches.memory.WritableMemory destination, long dstOffsetBytes, long lengthBytes) - Specified by:
copyToin interfaceorg.apache.datasketches.memory.Memory
-
writeTo
- Specified by:
writeToin interfaceorg.apache.datasketches.memory.Memory- Throws:
IOException
-
equalTo
- Specified by:
equalToin interfaceorg.apache.datasketches.memory.BaseState
-
writableRegion
public org.apache.datasketches.memory.WritableMemory writableRegion(long offsetBytes, long capacityBytes, ByteOrder byteOrder) - Specified by:
writableRegionin interfaceorg.apache.datasketches.memory.WritableMemory
-
asWritableBuffer
- Specified by:
asWritableBufferin interfaceorg.apache.datasketches.memory.WritableMemory
-
putBooleanArray
public void putBooleanArray(long offsetBytes, boolean[] srcArray, int srcOffsetBooleans, int lengthBooleans) - Specified by:
putBooleanArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putByteArray
public void putByteArray(long offsetBytes, byte[] srcArray, int srcOffsetBytes, int lengthBytes) - Specified by:
putByteArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putCharArray
public void putCharArray(long offsetBytes, char[] srcArray, int srcOffsetChars, int lengthChars) - Specified by:
putCharArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putCharsToUtf8
- Specified by:
putCharsToUtf8in interfaceorg.apache.datasketches.memory.WritableMemory
-
putDoubleArray
public void putDoubleArray(long offsetBytes, double[] srcArray, int srcOffsetDoubles, int lengthDoubles) - Specified by:
putDoubleArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putFloatArray
public void putFloatArray(long offsetBytes, float[] srcArray, int srcOffsetFloats, int lengthFloats) - Specified by:
putFloatArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putIntArray
public void putIntArray(long offsetBytes, int[] srcArray, int srcOffsetInts, int lengthInts) - Specified by:
putIntArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putLongArray
public void putLongArray(long offsetBytes, long[] srcArray, int srcOffsetLongs, int lengthLongs) - Specified by:
putLongArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
putShortArray
public void putShortArray(long offsetBytes, short[] srcArray, int srcOffsetShorts, int lengthShorts) - Specified by:
putShortArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
getAndAddLong
public long getAndAddLong(long offsetBytes, long delta) - Specified by:
getAndAddLongin interfaceorg.apache.datasketches.memory.WritableMemory
-
compareAndSwapLong
public boolean compareAndSwapLong(long offsetBytes, long expect, long update) - Specified by:
compareAndSwapLongin interfaceorg.apache.datasketches.memory.WritableMemory
-
getAndSetLong
public long getAndSetLong(long offsetBytes, long newValue) - Specified by:
getAndSetLongin interfaceorg.apache.datasketches.memory.WritableMemory
-
getArray
- Specified by:
getArrayin interfaceorg.apache.datasketches.memory.WritableMemory
-
clear
public void clear()- Specified by:
clearin interfaceorg.apache.datasketches.memory.WritableMemory
-
clear
public void clear(long offsetBytes, long lengthBytes) - Specified by:
clearin interfaceorg.apache.datasketches.memory.WritableMemory
-
clearBits
public void clearBits(long offsetBytes, byte bitMask) - Specified by:
clearBitsin interfaceorg.apache.datasketches.memory.WritableMemory
-
fill
public void fill(byte value) - Specified by:
fillin interfaceorg.apache.datasketches.memory.WritableMemory
-
fill
public void fill(long offsetBytes, long lengthBytes, byte value) - Specified by:
fillin interfaceorg.apache.datasketches.memory.WritableMemory
-
setBits
public void setBits(long offsetBytes, byte bitMask) - Specified by:
setBitsin interfaceorg.apache.datasketches.memory.WritableMemory
-