Class TypeStrategies

java.lang.Object
org.apache.druid.segment.column.TypeStrategies

public class TypeStrategies extends Object
  • Field Details

  • Constructor Details

    • TypeStrategies

      public TypeStrategies()
  • Method Details

    • getComplex

      @Nullable public static TypeStrategy<?> getComplex(String typeName)
    • registerComplex

      public static void registerComplex(String typeName, TypeStrategy<?> strategy)
      hmm... this might look familiar... (see ComplexMetrics)

      Register a complex type name -> TypeStrategy mapping.

      If the specified type name is already used and the supplied TypeStrategy is not of the same type as the existing value in the map for said key, an ISE is thrown.

      Parameters:
      strategy - The TypeStrategy object to be associated with the 'type' in the map.
    • writeNull

      public static int writeNull(ByteBuffer buffer, int offset)
      Clear and set the 'null' byte of a nullable value to IS_NULL_BYTE to a ByteBuffer at the supplied position. This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

      Nullable types are stored with a leading byte to indicate if the value is null, followed by the value bytes (if not null)

      layout: | null (byte) | value |

      Returns:
      number of bytes written (always 1)
    • isNullableNull

      public static boolean isNullableNull(ByteBuffer buffer, int offset)
      Checks if a 'nullable' value's null byte is set to IS_NULL_BYTE. This method will mask the value of the null byte to only check if the null bit is set, meaning that the higher bits can be utilized for flags as necessary (e.g. using high bits to indicate if the value has been set or not for aggregators).

      Note that writing nullable values with the methods of Types will always clear and set the null byte to either IS_NULL_BYTE or IS_NOT_NULL_BYTE, losing any flag bits.

      layout: | null (byte) | value |

    • writeNotNullNullableLong

      public static int writeNotNullNullableLong(ByteBuffer buffer, int offset, long value)
      Write a non-null long value to a ByteBuffer at the supplied offset. The first byte is always cleared and set to IS_NOT_NULL_BYTE, the long value is written in the next 8 bytes.

      layout: | null (byte) | long |

      This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

      Returns:
      number of bytes written (always 9)
    • readNotNullNullableLong

      public static long readNotNullNullableLong(ByteBuffer buffer, int offset)
      Reads a non-null long value from a ByteBuffer at the supplied offset. This method should only be called if and only if isNullableNull(java.nio.ByteBuffer, int) for the same offset returns false.

      layout: | null (byte) | long |

      This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

    • writeNotNullNullableDouble

      public static int writeNotNullNullableDouble(ByteBuffer buffer, int offset, double value)
      Write a non-null double value to a ByteBuffer at the supplied offset. The first byte is always cleared and set to IS_NOT_NULL_BYTE, the double value is written in the next 8 bytes.

      layout: | null (byte) | double |

      This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

      Returns:
      number of bytes written (always 9)
    • readNotNullNullableDouble

      public static double readNotNullNullableDouble(ByteBuffer buffer, int offset)
      Reads a non-null double value from a ByteBuffer at the supplied offset. This method should only be called if and only if isNullableNull(java.nio.ByteBuffer, int) for the same offset returns false.

      layout: | null (byte) | double |

      This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

    • writeNotNullNullableFloat

      public static int writeNotNullNullableFloat(ByteBuffer buffer, int offset, float value)
      Write a non-null float value to a ByteBuffer at the supplied offset. The first byte is always cleared and set to IS_NOT_NULL_BYTE, the float value is written in the next 4 bytes.

      layout: | null (byte) | float |

      This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

      Returns:
      number of bytes written (always 5)
    • readNotNullNullableFloat

      public static float readNotNullNullableFloat(ByteBuffer buffer, int offset)
      Reads a non-null float value from a ByteBuffer at the supplied offset. This method should only be called if and only if isNullableNull(java.nio.ByteBuffer, int) for the same offset returns false.

      layout: | null (byte) | float |

      This method does not change the buffer position, limit, or mark, because it does not expect to own the buffer given to it (i.e. buffer aggs)

    • checkMaxSize

      public static void checkMaxSize(int available, int maxSizeBytes, TypeSignature<?> signature)