Package org.apache.druid.segment.data
Interface ObjectStrategy<T>
- All Superinterfaces:
Comparator<T>
- All Known Implementing Classes:
DecompressingByteBufferObjectStrategy,ImmutableRTreeObjectStrategy
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanWhetherComparator.compare(T, T)is valid or not.fromByteBuffer(ByteBuffer buffer, int numBytes) Convert values from their underlying byte representation.default TfromByteBufferSafe(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 TfromByteBufferWithSize(ByteBuffer buffer) Reads 4-bytes numBytes from the given buffer, and then delegates tofromByteBuffer(ByteBuffer, int).getClazz()default booleanWhether thefromByteBuffer(ByteBuffer, int),fromByteBufferWithSize(ByteBuffer), andfromByteBufferSafe(ByteBuffer, int)methods return an object that may retain a reference to the underlying memory provided by aByteBuffer.byte[]default voidwriteTo(T val, WriteOutBytes out) Methods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
getClazz
-
fromByteBuffer
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
-
toBytes
-
canCompare
default boolean canCompare()WhetherComparator.compare(T, T)is valid or not. -
readRetainsBufferReference
default boolean readRetainsBufferReference()Whether thefromByteBuffer(ByteBuffer, int),fromByteBufferWithSize(ByteBuffer), andfromByteBufferSafe(ByteBuffer, int)methods return an object that may retain a reference to the underlying memory provided by aByteBuffer. If a reference is sometimes retained, this method returns true. It returns false if, and only if, a reference is *never* retained.If this method returns true, and the caller does not control the lifecycle of the underlying memory or cannot ensure that it will not change over the lifetime of the returned object, callers should copy the memory to a new location that they do control the lifecycle of and will be available for the duration of the returned object.
-
fromByteBufferWithSize
Reads 4-bytes numBytes from the given buffer, and then delegates tofromByteBuffer(ByteBuffer, int). -
writeTo
- Throws:
IOException
-
fromByteBufferSafe
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 theByteBuffermethods, or usingSafeWritableMemoryifMemoryis 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
-