Package org.apache.druid.segment.data
Interface ObjectStrategy<T>
-
- All Superinterfaces:
Comparator<T>
- All Known Implementing Classes:
DecompressingByteBufferObjectStrategy
,ImmutableRTreeObjectStrategy
public interface ObjectStrategy<T> extends Comparator<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
canCompare()
WhetherComparator.compare(T, T)
is valid or not.T
fromByteBuffer(ByteBuffer buffer, int numBytes)
Convert values from their underlying byte representation.default T
fromByteBufferSafe(ByteBuffer buffer, int numBytes)
Convert values from their underlying byte representation, when the underlying bytes might be corrupted or maliciously constructed Implementations of this method absolutely must never perform any sun.misc.Unsafe based memory read or write operations from instructions contained in the data read from this buffer without first validating the data.default T
fromByteBufferWithSize(ByteBuffer buffer)
Reads 4-bytes numBytes from the given buffer, and then delegates tofromByteBuffer(ByteBuffer, int)
.Class<? extends T>
getClazz()
byte[]
toBytes(T val)
default void
writeTo(T val, WriteOutBytes out)
-
Methods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
fromByteBuffer
@Nullable T fromByteBuffer(ByteBuffer buffer, int numBytes)
Convert values from their underlying byte representation. Implementations of this method may change the given buffer's mark, or limit, and position. Implementations of this method may not store the given buffer in a field of the "deserialized" object, need to useByteBuffer.slice()
,ByteBuffer.asReadOnlyBuffer()
orByteBuffer.duplicate()
in this case.- Parameters:
buffer
- buffer to read value fromnumBytes
- number of bytes used to store the value, starting at buffer.position()- Returns:
- an object created from the given byte buffer representation
-
canCompare
default boolean canCompare()
WhetherComparator.compare(T, T)
is valid or not.
-
fromByteBufferWithSize
default T fromByteBufferWithSize(ByteBuffer buffer)
Reads 4-bytes numBytes from the given buffer, and then delegates tofromByteBuffer(ByteBuffer, int)
.
-
writeTo
default void writeTo(T val, WriteOutBytes out) throws IOException
- Throws:
IOException
-
fromByteBufferSafe
@Nullable default T fromByteBufferSafe(ByteBuffer buffer, int numBytes)
Convert values from their underlying byte representation, when the underlying bytes might be corrupted or maliciously constructed Implementations of this method absolutely must never perform any sun.misc.Unsafe based memory read or write operations from instructions contained in the data read from this buffer without first validating the data. If the data cannot be validated, all read and write operations from instructions in this data must be done directly with theByteBuffer
methods, or usingSafeWritableMemory
ifMemory
is employed to materialize the value. Implementations of this method may change the given buffer's mark, or limit, and position. Implementations of this method may not store the given buffer in a field of the "deserialized" object, need to useByteBuffer.slice()
,ByteBuffer.asReadOnlyBuffer()
orByteBuffer.duplicate()
in this case.- Parameters:
buffer
- buffer to read value fromnumBytes
- number of bytes used to store the value, starting at buffer.position()- Returns:
- an object created from the given byte buffer representation
-
-