Class TypeStrategies.NestedDataTypeStrategy

java.lang.Object
org.apache.druid.segment.column.TypeStrategies.NestedDataTypeStrategy
All Implemented Interfaces:
it.unimi.dsi.fastutil.Hash.Strategy<Object>, Comparator<Object>, TypeStrategy<Object>
Enclosing class:
TypeStrategies

public static final class TypeStrategies.NestedDataTypeStrategy extends Object implements TypeStrategy<Object>
  • Constructor Details

    • NestedDataTypeStrategy

      public NestedDataTypeStrategy()
  • Method Details

    • estimateSizeBytes

      public int estimateSizeBytes(Object value)
      Description copied from interface: TypeStrategy
      Estimate the size in bytes that writing this value to memory would require. This method is not required to be exactly correct, but many implementations might be. Implementations should err on the side of over-estimating if exact sizing is not efficient. Example usage of this method is estimating heap memory usage for an aggregator or the amount of buffer which might need allocated to then TypeStrategy.write(java.nio.ByteBuffer, T, int) a value
      Specified by:
      estimateSizeBytes in interface TypeStrategy<Object>
    • read

      public Object read(ByteBuffer buffer)
      Description copied from interface: TypeStrategy
      Read a non-null value from the ByteBuffer at the current Buffer.position(). This will move the underlying position by the size of the value read. The value returned from this method may retain a reference to the provided ByteBuffer. If it does, then TypeStrategy.readRetainsBufferReference() returns true.
      Specified by:
      read in interface TypeStrategy<Object>
    • fromByteBuffer

      @Nullable public StructuredData fromByteBuffer(ByteBuffer buffer, int numBytes)
    • readRetainsBufferReference

      public boolean readRetainsBufferReference()
      Description copied from interface: TypeStrategy
      Whether the TypeStrategy.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.

      Specified by:
      readRetainsBufferReference in interface TypeStrategy<Object>
    • write

      public int write(ByteBuffer buffer, Object value, int maxSizeBytes)
      Description copied from interface: TypeStrategy
      Write a non-null value to the ByteBuffer at position Buffer.position(). This will move the underlying position by the size of the value written. This method returns the number of bytes written. If writing the value would take more than 'maxSizeBytes', this method will return a negative value indicating the number of additional bytes that would be required to fully write the value. Partial results may be written to the buffer when in this state, and the position may be left at whatever point the implementation ran out of space while writing the value. Callers should save the starting position if it is necessary to 'rewind' after a partial write. Callers MUST check that the return value is positive which indicates a successful write, while a negative response a partial write.
      Specified by:
      write in interface TypeStrategy<Object>
      Returns:
      number of bytes written
    • toBytes

      @Nullable public byte[] toBytes(@Nullable Object val)
    • compare

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

      public boolean groupable()
      Description copied from interface: TypeStrategy
      Whether the type is groupable or not. This is always true for all the primitive types, arrays, and nested arrays therefore the SQL and the native layer might ignore this flag for those types. For complex types, this flag can be true or false, depending on whether the semantics and implementation of the type naturally leads to groupability or not. For example, it makes sense for JSON columns to be groupable, however there is little sense in grouping sketches (before finalizing).

      If a type is groupable, following statements MUST hold:

      a. TypeStrategy.equals(Object, Object) must be implemented. It should return true if and only if two objects are equal and can be grouped together.

      b. TypeStrategy.hashCode(Object) must be implemented, and must be consistent with equals. It should return a hashCode for the given object. For two objects that are equal, it must return the same hash value. For two objects that are not equal, it can return the same hash value (or not). A conscious effort must be made to minimise collisions between the hash values of two non-equal objects for faster grouping.

      c. Comparator.compare(Object, Object) must be consistent with equals. Apart from abiding by the definition of Comparator.compare(T, T), it must not return 0 for two objects that are not equals, and converse must also hold, i.e. if the value returned by compare is not zero, then the arguments must not be equal.

      d. TypeStrategy.getClazz() should return the Java class for the dimension represented by the type. This will be used by the mapper to deserialize the object during tasks like broker-historical interaction and spilling to the disk.

      Specified by:
      groupable in interface TypeStrategy<Object>
    • hashCode

      public int hashCode(Object o)
      Specified by:
      hashCode in interface it.unimi.dsi.fastutil.Hash.Strategy<Object>
      Specified by:
      hashCode in interface TypeStrategy<Object>
      See Also:
    • equals

      public boolean equals(Object a, Object b)
      Specified by:
      equals in interface it.unimi.dsi.fastutil.Hash.Strategy<Object>
      Specified by:
      equals in interface TypeStrategy<Object>
      See Also:
    • getClazz

      public Class<?> getClazz()
      Specified by:
      getClazz in interface TypeStrategy<Object>
      See Also: