public class SafeWritableMemory extends SafeWritableBase implements org.apache.datasketches.memory.WritableMemory
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'.
| Constructor and Description |
|---|
SafeWritableMemory(ByteBuffer buffer) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.datasketches.memory.Buffer |
asBuffer(ByteOrder byteOrder) |
org.apache.datasketches.memory.WritableBuffer |
asWritableBuffer(ByteOrder byteOrder) |
void |
clear() |
void |
clear(long offsetBytes,
long lengthBytes) |
void |
clearBits(long offsetBytes,
byte bitMask) |
boolean |
compareAndSwapLong(long offsetBytes,
long expect,
long update) |
int |
compareTo(long thisOffsetBytes,
long thisLengthBytes,
org.apache.datasketches.memory.Memory that,
long thatOffsetBytes,
long thatLengthBytes) |
void |
copyTo(long srcOffsetBytes,
org.apache.datasketches.memory.WritableMemory destination,
long dstOffsetBytes,
long lengthBytes) |
boolean |
equalTo(long thisOffsetBytes,
Object that,
long thatOffsetBytes,
long lengthBytes) |
void |
fill(byte value) |
void |
fill(long offsetBytes,
long lengthBytes,
byte value) |
long |
getAndAddLong(long offsetBytes,
long delta) |
long |
getAndSetLong(long offsetBytes,
long newValue) |
Object |
getArray() |
void |
getBooleanArray(long offsetBytes,
boolean[] dstArray,
int dstOffsetBooleans,
int lengthBooleans) |
void |
getByteArray(long offsetBytes,
byte[] dstArray,
int dstOffsetBytes,
int lengthBytes) |
void |
getCharArray(long offsetBytes,
char[] dstArray,
int dstOffsetChars,
int lengthChars) |
int |
getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
Appendable dst) |
int |
getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
StringBuilder dst) |
void |
getDoubleArray(long offsetBytes,
double[] dstArray,
int dstOffsetDoubles,
int lengthDoubles) |
void |
getFloatArray(long offsetBytes,
float[] dstArray,
int dstOffsetFloats,
int lengthFloats) |
void |
getIntArray(long offsetBytes,
int[] dstArray,
int dstOffsetInts,
int lengthInts) |
void |
getLongArray(long offsetBytes,
long[] dstArray,
int dstOffsetLongs,
int lengthLongs) |
void |
getShortArray(long offsetBytes,
short[] dstArray,
int dstOffsetShorts,
int lengthShorts) |
void |
putBooleanArray(long offsetBytes,
boolean[] srcArray,
int srcOffsetBooleans,
int lengthBooleans) |
void |
putByteArray(long offsetBytes,
byte[] srcArray,
int srcOffsetBytes,
int lengthBytes) |
void |
putCharArray(long offsetBytes,
char[] srcArray,
int srcOffsetChars,
int lengthChars) |
long |
putCharsToUtf8(long offsetBytes,
CharSequence src) |
void |
putDoubleArray(long offsetBytes,
double[] srcArray,
int srcOffsetDoubles,
int lengthDoubles) |
void |
putFloatArray(long offsetBytes,
float[] srcArray,
int srcOffsetFloats,
int lengthFloats) |
void |
putIntArray(long offsetBytes,
int[] srcArray,
int srcOffsetInts,
int lengthInts) |
void |
putLongArray(long offsetBytes,
long[] srcArray,
int srcOffsetLongs,
int lengthLongs) |
void |
putShortArray(long offsetBytes,
short[] srcArray,
int srcOffsetShorts,
int lengthShorts) |
org.apache.datasketches.memory.Memory |
region(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder) |
void |
setBits(long offsetBytes,
byte bitMask) |
static SafeWritableMemory |
wrap(byte[] bytes) |
static SafeWritableMemory |
wrap(ByteBuffer buffer) |
static SafeWritableMemory |
wrap(ByteBuffer buffer,
ByteOrder byteOrder) |
static SafeWritableMemory |
wrap(ByteBuffer buffer,
int offset,
int size) |
org.apache.datasketches.memory.WritableMemory |
writableRegion(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder) |
void |
writeTo(long offsetBytes,
long lengthBytes,
WritableByteChannel out) |
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, xxHash64clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitallocate, allocate, allocate, allocateDirect, allocateDirect, asWritableBuffer, getMemoryRequestServer, putBoolean, putByte, putChar, putDouble, putFloat, putInt, putLong, putShort, writableMap, writableMap, writableRegion, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrap, writableWrapasBuffer, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getShort, map, map, region, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapcheckValidAndBounds, equals, getByteBuffer, getCapacity, getCumulativeOffset, getCumulativeOffset, getCurrentDirectMemoryAllocated, getCurrentDirectMemoryAllocations, getCurrentDirectMemoryMapAllocated, getCurrentDirectMemoryMapAllocations, getRegionOffset, getRegionOffset, getTypeByteOrder, hasArray, hasByteBuffer, hashCode, isByteOrderCompatible, isDirect, isReadOnly, isSameResource, isValid, toHexString, xxHash64, xxHash64public SafeWritableMemory(ByteBuffer buffer)
public static SafeWritableMemory wrap(byte[] bytes)
wrap in interface org.apache.datasketches.memory.Memorypublic static SafeWritableMemory wrap(ByteBuffer buffer)
wrap in interface org.apache.datasketches.memory.Memorypublic static SafeWritableMemory wrap(ByteBuffer buffer, ByteOrder byteOrder)
wrap in interface org.apache.datasketches.memory.Memorypublic static SafeWritableMemory wrap(ByteBuffer buffer, int offset, int size)
public org.apache.datasketches.memory.Memory region(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder)
region in interface org.apache.datasketches.memory.Memorypublic org.apache.datasketches.memory.Buffer asBuffer(ByteOrder byteOrder)
asBuffer in interface org.apache.datasketches.memory.Memorypublic void getBooleanArray(long offsetBytes,
boolean[] dstArray,
int dstOffsetBooleans,
int lengthBooleans)
getBooleanArray in interface org.apache.datasketches.memory.Memorypublic void getByteArray(long offsetBytes,
byte[] dstArray,
int dstOffsetBytes,
int lengthBytes)
getByteArray in interface org.apache.datasketches.memory.Memorypublic void getCharArray(long offsetBytes,
char[] dstArray,
int dstOffsetChars,
int lengthChars)
getCharArray in interface org.apache.datasketches.memory.Memorypublic int getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
Appendable dst)
throws IOException,
org.apache.datasketches.memory.Utf8CodingException
getCharsFromUtf8 in interface org.apache.datasketches.memory.MemoryIOExceptionorg.apache.datasketches.memory.Utf8CodingExceptionpublic int getCharsFromUtf8(long offsetBytes,
int utf8LengthBytes,
StringBuilder dst)
throws org.apache.datasketches.memory.Utf8CodingException
getCharsFromUtf8 in interface org.apache.datasketches.memory.Memoryorg.apache.datasketches.memory.Utf8CodingExceptionpublic void getDoubleArray(long offsetBytes,
double[] dstArray,
int dstOffsetDoubles,
int lengthDoubles)
getDoubleArray in interface org.apache.datasketches.memory.Memorypublic void getFloatArray(long offsetBytes,
float[] dstArray,
int dstOffsetFloats,
int lengthFloats)
getFloatArray in interface org.apache.datasketches.memory.Memorypublic void getIntArray(long offsetBytes,
int[] dstArray,
int dstOffsetInts,
int lengthInts)
getIntArray in interface org.apache.datasketches.memory.Memorypublic void getLongArray(long offsetBytes,
long[] dstArray,
int dstOffsetLongs,
int lengthLongs)
getLongArray in interface org.apache.datasketches.memory.Memorypublic void getShortArray(long offsetBytes,
short[] dstArray,
int dstOffsetShorts,
int lengthShorts)
getShortArray in interface org.apache.datasketches.memory.Memorypublic int compareTo(long thisOffsetBytes,
long thisLengthBytes,
org.apache.datasketches.memory.Memory that,
long thatOffsetBytes,
long thatLengthBytes)
compareTo in interface org.apache.datasketches.memory.Memorypublic void copyTo(long srcOffsetBytes,
org.apache.datasketches.memory.WritableMemory destination,
long dstOffsetBytes,
long lengthBytes)
copyTo in interface org.apache.datasketches.memory.Memorypublic void writeTo(long offsetBytes,
long lengthBytes,
WritableByteChannel out)
throws IOException
writeTo in interface org.apache.datasketches.memory.MemoryIOExceptionpublic boolean equalTo(long thisOffsetBytes,
Object that,
long thatOffsetBytes,
long lengthBytes)
equalTo in interface org.apache.datasketches.memory.BaseStatepublic org.apache.datasketches.memory.WritableMemory writableRegion(long offsetBytes,
long capacityBytes,
ByteOrder byteOrder)
writableRegion in interface org.apache.datasketches.memory.WritableMemorypublic org.apache.datasketches.memory.WritableBuffer asWritableBuffer(ByteOrder byteOrder)
asWritableBuffer in interface org.apache.datasketches.memory.WritableMemorypublic void putBooleanArray(long offsetBytes,
boolean[] srcArray,
int srcOffsetBooleans,
int lengthBooleans)
putBooleanArray in interface org.apache.datasketches.memory.WritableMemorypublic void putByteArray(long offsetBytes,
byte[] srcArray,
int srcOffsetBytes,
int lengthBytes)
putByteArray in interface org.apache.datasketches.memory.WritableMemorypublic void putCharArray(long offsetBytes,
char[] srcArray,
int srcOffsetChars,
int lengthChars)
putCharArray in interface org.apache.datasketches.memory.WritableMemorypublic long putCharsToUtf8(long offsetBytes,
CharSequence src)
putCharsToUtf8 in interface org.apache.datasketches.memory.WritableMemorypublic void putDoubleArray(long offsetBytes,
double[] srcArray,
int srcOffsetDoubles,
int lengthDoubles)
putDoubleArray in interface org.apache.datasketches.memory.WritableMemorypublic void putFloatArray(long offsetBytes,
float[] srcArray,
int srcOffsetFloats,
int lengthFloats)
putFloatArray in interface org.apache.datasketches.memory.WritableMemorypublic void putIntArray(long offsetBytes,
int[] srcArray,
int srcOffsetInts,
int lengthInts)
putIntArray in interface org.apache.datasketches.memory.WritableMemorypublic void putLongArray(long offsetBytes,
long[] srcArray,
int srcOffsetLongs,
int lengthLongs)
putLongArray in interface org.apache.datasketches.memory.WritableMemorypublic void putShortArray(long offsetBytes,
short[] srcArray,
int srcOffsetShorts,
int lengthShorts)
putShortArray in interface org.apache.datasketches.memory.WritableMemorypublic long getAndAddLong(long offsetBytes,
long delta)
getAndAddLong in interface org.apache.datasketches.memory.WritableMemorypublic boolean compareAndSwapLong(long offsetBytes,
long expect,
long update)
compareAndSwapLong in interface org.apache.datasketches.memory.WritableMemorypublic long getAndSetLong(long offsetBytes,
long newValue)
getAndSetLong in interface org.apache.datasketches.memory.WritableMemorypublic Object getArray()
getArray in interface org.apache.datasketches.memory.WritableMemorypublic void clear()
clear in interface org.apache.datasketches.memory.WritableMemorypublic void clear(long offsetBytes,
long lengthBytes)
clear in interface org.apache.datasketches.memory.WritableMemorypublic void clearBits(long offsetBytes,
byte bitMask)
clearBits in interface org.apache.datasketches.memory.WritableMemorypublic void fill(byte value)
fill in interface org.apache.datasketches.memory.WritableMemorypublic void fill(long offsetBytes,
long lengthBytes,
byte value)
fill in interface org.apache.datasketches.memory.WritableMemorypublic void setBits(long offsetBytes,
byte bitMask)
setBits in interface org.apache.datasketches.memory.WritableMemoryCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.