Class ReinterpretUtilities

java.lang.Object
com.illumon.iris.db.v2.sources.ReinterpretUtilities

public class ReinterpretUtilities extends Object
A set of static utilities for reinterpreting ColumnSources as other types.
  • Constructor Details

    • ReinterpretUtilities

      public ReinterpretUtilities()
  • Method Details

    • isZonelessTimeType

      public static boolean isZonelessTimeType(@NotNull Class<?> type)
      Check if the type is a zoneless time type.
      Parameters:
      type - the type.
      Returns:
      true if it is a zoneless time type
    • timeToEpochLongSource

      public static ColumnSource<Long> timeToEpochLongSource(@NotNull ColumnSource<?> columnSource)
      Convert any time source to a long source containing nanos of epoch.
      Parameters:
      columnSource - the original source
      Returns:
      the source reinterpreted as a long of epoch.
    • instantToLongSource

      @NotNull public static ColumnSource<Long> instantToLongSource(@NotNull ColumnSource<?> source)
      Given an Instant column source turn it into a long column source, either via reinterpretation or wrapping.
      Parameters:
      source - the source to turn into a long source
      Returns:
      the long source
    • zonedDateTimeToLongSource

      @NotNull public static ColumnSource<Long> zonedDateTimeToLongSource(@NotNull ColumnSource<?> source)
      Given a ZonedDateTime column source turn it into a long column source, either via reinterpretation or wrapping.
      Parameters:
      source - the source to turn into a long source
      Returns:
      the long source
    • dateTimeToLongSource

      public static ColumnSource<Long> dateTimeToLongSource(@NotNull ColumnSource<?> source)
      Given a DateTime column source turn it into a long column source, either via reinterpretation or wrapping.
      Parameters:
      source - the source to turn into a long source
      Returns:
      the long source
    • booleanToByteSource

      public static ColumnSource<Byte> booleanToByteSource(@NotNull ColumnSource<?> source)
      Given a Boolean column source turn it into a byte column source, either via reinterpretation or wrapping.
      Parameters:
      source - the source to turn into a byte source
      Returns:
      the byte source
    • maybeConvertToPrimitive

      public static ColumnSource<?> maybeConvertToPrimitive(@NotNull ColumnSource<?> source)
      If source is something that we prefer to handle as a primitive, do the appropriate conversion.
      Parameters:
      source - The source to convert
      Returns:
      If possible, the source converted to a primitive, otherwise the source
    • convertToOriginal

      public static ColumnSource<?> convertToOriginal(@NotNull Class<?> originalType, @NotNull ColumnSource<?> source)
      Reinterpret or box ColumnSource back to its original type.
      Parameters:
      originalType - The type to convert to
      source - The source to convert
      Returns:
      Reinterpret or box source back to the original type if possible
    • maybeConvertToWritablePrimitiveChunkType

      @NotNull public static ChunkType maybeConvertToWritablePrimitiveChunkType(@NotNull Class<?> dataType)
      If dataType is something that we prefer to handle as a primitive, emit the appropriate ChunkType, else the normal ChunkType for the data type.
      Parameters:
      dataType - The data type to convert to a ChunkType
      Returns:
      the appropriate ChunkType to use when writing primitives to the destination