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 regularByteBufferlook like aMemoryorBuffer. All methods delegate directly to theByteBufferrather 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 voidcheckValidAndBounds(long offsetBytes, long lengthBytes)booleangetBoolean(long offsetBytes)bytegetByte(long offsetBytes)ByteBuffergetByteBuffer()longgetCapacity()chargetChar(long offsetBytes)longgetCumulativeOffset()longgetCumulativeOffset(long offsetBytes)doublegetDouble(long offsetBytes)floatgetFloat(long offsetBytes)intgetInt(long offsetBytes)longgetLong(long offsetBytes)org.apache.datasketches.memory.MemoryRequestServergetMemoryRequestServer()longgetRegionOffset()longgetRegionOffset(long offsetBytes)shortgetShort(long offsetBytes)ByteOrdergetTypeByteOrder()booleanhasArray()booleanhasByteBuffer()booleanisByteOrderCompatible(ByteOrder byteOrder)booleanisDirect()booleanisReadOnly()booleanisSameResource(Object that)booleanisValid()voidputBoolean(long offsetBytes, boolean value)voidputByte(long offsetBytes, byte value)voidputChar(long offsetBytes, char value)voidputDouble(long offsetBytes, double value)voidputFloat(long offsetBytes, float value)voidputInt(long offsetBytes, int value)voidputLong(long offsetBytes, long value)voidputShort(long offsetBytes, short value)StringtoHexString(String header, long offsetBytes, int lengthBytes)Adapted fromBaseStateImpl.toHexString(String, long, int)longxxHash64(long in, long seed)longxxHash64(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:
getTypeByteOrderin interfaceorg.apache.datasketches.memory.BaseState
-
isByteOrderCompatible
public boolean isByteOrderCompatible(ByteOrder byteOrder)
- Specified by:
isByteOrderCompatiblein interfaceorg.apache.datasketches.memory.BaseState
-
getByteBuffer
public ByteBuffer getByteBuffer()
- Specified by:
getByteBufferin interfaceorg.apache.datasketches.memory.BaseState
-
getCapacity
public long getCapacity()
- Specified by:
getCapacityin interfaceorg.apache.datasketches.memory.BaseState
-
getCumulativeOffset
public long getCumulativeOffset()
- Specified by:
getCumulativeOffsetin interfaceorg.apache.datasketches.memory.BaseState
-
getCumulativeOffset
public long getCumulativeOffset(long offsetBytes)
- Specified by:
getCumulativeOffsetin interfaceorg.apache.datasketches.memory.BaseState
-
getRegionOffset
public long getRegionOffset()
- Specified by:
getRegionOffsetin interfaceorg.apache.datasketches.memory.BaseState
-
getRegionOffset
public long getRegionOffset(long offsetBytes)
- Specified by:
getRegionOffsetin interfaceorg.apache.datasketches.memory.BaseState
-
hasArray
public boolean hasArray()
- Specified by:
hasArrayin interfaceorg.apache.datasketches.memory.BaseState
-
xxHash64
public long xxHash64(long offsetBytes, long lengthBytes, long seed)- Specified by:
xxHash64in interfaceorg.apache.datasketches.memory.BaseState
-
xxHash64
public long xxHash64(long in, long seed)- Specified by:
xxHash64in interfaceorg.apache.datasketches.memory.BaseState
-
hasByteBuffer
public boolean hasByteBuffer()
- Specified by:
hasByteBufferin interfaceorg.apache.datasketches.memory.BaseState
-
isDirect
public boolean isDirect()
- Specified by:
isDirectin interfaceorg.apache.datasketches.memory.BaseState
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin interfaceorg.apache.datasketches.memory.BaseState
-
isSameResource
public boolean isSameResource(Object that)
- Specified by:
isSameResourcein interfaceorg.apache.datasketches.memory.BaseState
-
isValid
public boolean isValid()
- Specified by:
isValidin interfaceorg.apache.datasketches.memory.BaseState
-
checkValidAndBounds
public void checkValidAndBounds(long offsetBytes, long lengthBytes)- Specified by:
checkValidAndBoundsin interfaceorg.apache.datasketches.memory.BaseState
-
-