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 Details

    • NullableTypeStrategy

      public NullableTypeStrategy(TypeStrategy<T> delegate)
  • Method Details

    • estimateSizeBytes

      public int estimateSizeBytes(@Nullable T value)
    • read

      @Nullable public T read(ByteBuffer buffer)
    • write

      @CheckReturnValue public int write(ByteBuffer buffer, @Nullable T value, int maxSizeBytes)
    • read

      @Nullable public T read(ByteBuffer buffer, int offset)
    • readRetainsBufferReference

      public boolean readRetainsBufferReference()
      Whether the read(java.nio.ByteBuffer) methods return an object that may retain a reference to the underlying memory of the provided ByteBuffer. 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

      public int compare(@Nullable T o1, @Nullable T o2)
      Specified by:
      compare in interface Comparator<T>
    • groupable

      public boolean groupable()
    • hashCode

      public int hashCode(@Nullable T o)
      Specified by:
      hashCode in interface it.unimi.dsi.fastutil.Hash.Strategy<T>
    • equals

      public boolean equals(@Nullable T a, @Nullable T b)
      Specified by:
      equals in interface it.unimi.dsi.fastutil.Hash.Strategy<T>
    • getClazz

      public Class<?> getClazz()