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 regular ByteBuffer look like a Memory or Buffer. All methods delegate directly to the ByteBuffer rather than using 'unsafe' reads.
See Also:
  • Constructor Details

    • SafeWritableBase

      public SafeWritableBase(ByteBuffer buffer)
  • Method Details

    • 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 interface org.apache.datasketches.memory.BaseState
    • isByteOrderCompatible

      public boolean isByteOrderCompatible(ByteOrder byteOrder)
      Specified by:
      isByteOrderCompatible in interface org.apache.datasketches.memory.BaseState
    • getByteBuffer

      public ByteBuffer getByteBuffer()
      Specified by:
      getByteBuffer in interface org.apache.datasketches.memory.BaseState
    • getCapacity

      public long getCapacity()
      Specified by:
      getCapacity in interface org.apache.datasketches.memory.BaseState
    • getCumulativeOffset

      public long getCumulativeOffset()
      Specified by:
      getCumulativeOffset in interface org.apache.datasketches.memory.BaseState
    • getCumulativeOffset

      public long getCumulativeOffset(long offsetBytes)
      Specified by:
      getCumulativeOffset in interface org.apache.datasketches.memory.BaseState
    • getRegionOffset

      public long getRegionOffset()
      Specified by:
      getRegionOffset in interface org.apache.datasketches.memory.BaseState
    • getRegionOffset

      public long getRegionOffset(long offsetBytes)
      Specified by:
      getRegionOffset in interface org.apache.datasketches.memory.BaseState
    • hasArray

      public boolean hasArray()
      Specified by:
      hasArray in interface org.apache.datasketches.memory.BaseState
    • xxHash64

      public long xxHash64(long offsetBytes, long lengthBytes, long seed)
      Specified by:
      xxHash64 in interface org.apache.datasketches.memory.BaseState
    • xxHash64

      public long xxHash64(long in, long seed)
      Specified by:
      xxHash64 in interface org.apache.datasketches.memory.BaseState
    • hasByteBuffer

      public boolean hasByteBuffer()
      Specified by:
      hasByteBuffer in interface org.apache.datasketches.memory.BaseState
    • isDirect

      public boolean isDirect()
      Specified by:
      isDirect in interface org.apache.datasketches.memory.BaseState
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface org.apache.datasketches.memory.BaseState
    • isSameResource

      public boolean isSameResource(Object that)
      Specified by:
      isSameResource in interface org.apache.datasketches.memory.BaseState
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface org.apache.datasketches.memory.BaseState
    • checkValidAndBounds

      public void checkValidAndBounds(long offsetBytes, long lengthBytes)
      Specified by:
      checkValidAndBounds in interface org.apache.datasketches.memory.BaseState
    • toHexString

      public String toHexString(String header, long offsetBytes, int lengthBytes)
      Adapted from BaseStateImpl.toHexString(String, long, int)
      Specified by:
      toHexString in interface org.apache.datasketches.memory.BaseState