Package org.apache.druid.segment.data
Class SafeWritableBase
- java.lang.Object
-
- org.apache.druid.segment.data.SafeWritableBase
-
- All Implemented Interfaces:
org.apache.datasketches.memory.BaseState
- Direct Known Subclasses:
SafeWritableBuffer
,SafeWritableMemory
public abstract class SafeWritableBase extends Object implements org.apache.datasketches.memory.BaseState
Base class for making a regularByteBuffer
look like aMemory
orBuffer
. All methods delegate directly to theByteBuffer
rather than using 'unsafe' reads.- See Also:
SafeWritableMemory
,SafeWritableBuffer
-
-
Constructor Summary
Constructors Constructor Description SafeWritableBase(ByteBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkValidAndBounds(long offsetBytes, long lengthBytes)
boolean
getBoolean(long offsetBytes)
byte
getByte(long offsetBytes)
ByteBuffer
getByteBuffer()
long
getCapacity()
char
getChar(long offsetBytes)
long
getCumulativeOffset()
long
getCumulativeOffset(long offsetBytes)
double
getDouble(long offsetBytes)
float
getFloat(long offsetBytes)
int
getInt(long offsetBytes)
long
getLong(long offsetBytes)
org.apache.datasketches.memory.MemoryRequestServer
getMemoryRequestServer()
long
getRegionOffset()
long
getRegionOffset(long offsetBytes)
short
getShort(long offsetBytes)
ByteOrder
getTypeByteOrder()
boolean
hasArray()
boolean
hasByteBuffer()
boolean
isByteOrderCompatible(ByteOrder byteOrder)
boolean
isDirect()
boolean
isReadOnly()
boolean
isSameResource(Object that)
boolean
isValid()
void
putBoolean(long offsetBytes, boolean value)
void
putByte(long offsetBytes, byte value)
void
putChar(long offsetBytes, char value)
void
putDouble(long offsetBytes, double value)
void
putFloat(long offsetBytes, float value)
void
putInt(long offsetBytes, int value)
void
putLong(long offsetBytes, long value)
void
putShort(long offsetBytes, short value)
String
toHexString(String header, long offsetBytes, int lengthBytes)
Adapted fromBaseStateImpl.toHexString(String, long, int)
long
xxHash64(long in, long seed)
long
xxHash64(long offsetBytes, long lengthBytes, long seed)
-
-
-
Constructor Detail
-
SafeWritableBase
public SafeWritableBase(ByteBuffer buffer)
-
-
Method Detail
-
getMemoryRequestServer
public org.apache.datasketches.memory.MemoryRequestServer getMemoryRequestServer()
-
getBoolean
public boolean getBoolean(long offsetBytes)
-
getByte
public byte getByte(long offsetBytes)
-
getChar
public char getChar(long offsetBytes)
-
getDouble
public double getDouble(long offsetBytes)
-
getFloat
public float getFloat(long offsetBytes)
-
getInt
public int getInt(long offsetBytes)
-
getLong
public long getLong(long offsetBytes)
-
getShort
public short getShort(long offsetBytes)
-
putBoolean
public void putBoolean(long offsetBytes, boolean value)
-
putByte
public void putByte(long offsetBytes, byte value)
-
putChar
public void putChar(long offsetBytes, char value)
-
putDouble
public void putDouble(long offsetBytes, double value)
-
putFloat
public void putFloat(long offsetBytes, float value)
-
putInt
public void putInt(long offsetBytes, int value)
-
putLong
public void putLong(long offsetBytes, long value)
-
putShort
public void putShort(long offsetBytes, short value)
-
getTypeByteOrder
public ByteOrder getTypeByteOrder()
- Specified by:
getTypeByteOrder
in interfaceorg.apache.datasketches.memory.BaseState
-
isByteOrderCompatible
public boolean isByteOrderCompatible(ByteOrder byteOrder)
- Specified by:
isByteOrderCompatible
in interfaceorg.apache.datasketches.memory.BaseState
-
getByteBuffer
public ByteBuffer getByteBuffer()
- Specified by:
getByteBuffer
in interfaceorg.apache.datasketches.memory.BaseState
-
getCapacity
public long getCapacity()
- Specified by:
getCapacity
in interfaceorg.apache.datasketches.memory.BaseState
-
getCumulativeOffset
public long getCumulativeOffset()
- Specified by:
getCumulativeOffset
in interfaceorg.apache.datasketches.memory.BaseState
-
getCumulativeOffset
public long getCumulativeOffset(long offsetBytes)
- Specified by:
getCumulativeOffset
in interfaceorg.apache.datasketches.memory.BaseState
-
getRegionOffset
public long getRegionOffset()
- Specified by:
getRegionOffset
in interfaceorg.apache.datasketches.memory.BaseState
-
getRegionOffset
public long getRegionOffset(long offsetBytes)
- Specified by:
getRegionOffset
in interfaceorg.apache.datasketches.memory.BaseState
-
hasArray
public boolean hasArray()
- Specified by:
hasArray
in interfaceorg.apache.datasketches.memory.BaseState
-
xxHash64
public long xxHash64(long offsetBytes, long lengthBytes, long seed)
- Specified by:
xxHash64
in interfaceorg.apache.datasketches.memory.BaseState
-
xxHash64
public long xxHash64(long in, long seed)
- Specified by:
xxHash64
in interfaceorg.apache.datasketches.memory.BaseState
-
hasByteBuffer
public boolean hasByteBuffer()
- Specified by:
hasByteBuffer
in interfaceorg.apache.datasketches.memory.BaseState
-
isDirect
public boolean isDirect()
- Specified by:
isDirect
in interfaceorg.apache.datasketches.memory.BaseState
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceorg.apache.datasketches.memory.BaseState
-
isSameResource
public boolean isSameResource(Object that)
- Specified by:
isSameResource
in interfaceorg.apache.datasketches.memory.BaseState
-
isValid
public boolean isValid()
- Specified by:
isValid
in interfaceorg.apache.datasketches.memory.BaseState
-
checkValidAndBounds
public void checkValidAndBounds(long offsetBytes, long lengthBytes)
- Specified by:
checkValidAndBounds
in interfaceorg.apache.datasketches.memory.BaseState
-
-