Package org.apache.druid.segment.column
Class NullableTypeStrategy<T>
java.lang.Object
org.apache.druid.segment.column.NullableTypeStrategy<T>
- All Implemented Interfaces:
it.unimi.dsi.fastutil.Hash.Strategy<T>,Comparator<T>
public final class NullableTypeStrategy<T>
extends Object
implements Comparator<T>, it.unimi.dsi.fastutil.Hash.Strategy<T>
Wrapper of
TypeStrategy for nullable types, which stores TypeStrategies.IS_NULL_BYTE or
TypeStrategies.IS_NOT_NULL_BYTE in the leading byte of any value, as appropriate. If the value is null, only
TypeStrategies.IS_NULL_BYTE will be set, otherwise, the value bytes will be written after the null byte.
layout: | null (byte) | value (byte[]) |
This is not the most efficient way to track nulls, it is recommended to only use this wrapper if you MUST store null
values.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanintestimateSizeBytes(T value) Class<?> getClazz()booleanintread(ByteBuffer buffer) read(ByteBuffer buffer, int offset) booleanWhether theread(java.nio.ByteBuffer)methods return an object that may retain a reference to the underlying memory of the providedByteBuffer.intwrite(ByteBuffer buffer, int offset, T value, int maxSizeBytes) intwrite(ByteBuffer buffer, T value, int maxSizeBytes) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
NullableTypeStrategy
-
-
Method Details
-
estimateSizeBytes
-
read
-
write
-
read
-
readRetainsBufferReference
public boolean readRetainsBufferReference()Whether theread(java.nio.ByteBuffer)methods return an object that may retain a reference to the underlying memory of the providedByteBuffer. 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.
-
write
@CheckReturnValue public int write(ByteBuffer buffer, int offset, @Nullable T value, int maxSizeBytes) -
compare
- Specified by:
comparein interfaceComparator<T>
-
groupable
public boolean groupable() -
hashCode
- Specified by:
hashCodein interfaceit.unimi.dsi.fastutil.Hash.Strategy<T>
-
equals
- Specified by:
equalsin interfaceit.unimi.dsi.fastutil.Hash.Strategy<T>
-
getClazz
-