Class ReinterpretUtils

java.lang.Object
io.deephaven.engine.table.impl.sources.ReinterpretUtils

public class ReinterpretUtils extends Object
  • Constructor Details

    • ReinterpretUtils

      public ReinterpretUtils()
  • Method Details

    • byteToBooleanSource

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

      @NotNull public static @NotNull ColumnSource<Byte> booleanToByteSource(@NotNull @NotNull ColumnSource<Boolean> 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
    • writableBooleanToByteSource

      @Nullable public static @Nullable WritableColumnSource<Byte> writableBooleanToByteSource(@NotNull @NotNull WritableColumnSource<Boolean> source)
      Given a writable Boolean column source turn it into a writable byte column source via reinterpretation if possible.
      Parameters:
      source - the source to turn into a byte source
      Returns:
      the byte source or null if it could not be reinterpreted
    • longToInstantSource

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

      @NotNull public static @NotNull ColumnSource<Long> instantToLongSource(@NotNull @NotNull ColumnSource<Instant> 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
    • writableInstantToLongSource

      @Nullable public static @Nullable WritableColumnSource<Long> writableInstantToLongSource(@NotNull @NotNull WritableColumnSource<Instant> source)
      Given a writable Instant column source turn it into a writable long column source via reinterpretation if possible.
      Parameters:
      source - the source to turn into a long source
      Returns:
      the long source or null if it could not be reinterpreted
    • longToZonedDateTimeSource

      public static ColumnSource<ZonedDateTime> longToZonedDateTimeSource(@NotNull @NotNull ColumnSource<Long> source, @NotNull @NotNull ZoneId wrapperTimeZone)
      Given a long column source turn it into a ZonedDateTime column source, either via reinterpretation or wrapping.
      Parameters:
      source - the source to turn into a ZonedDateTime source
      wrapperTimeZone - the ZoneId to use if and only if we can't apply a simple reinterpret
      Returns:
      the long source
    • zonedDateTimeToLongSource

      @NotNull public static @NotNull ColumnSource<Long> zonedDateTimeToLongSource(@NotNull @NotNull ColumnSource<ZonedDateTime> 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
    • writableZonedDateTimeToLongSource

      @Nullable public static @Nullable WritableColumnSource<Long> writableZonedDateTimeToLongSource(@NotNull @NotNull WritableColumnSource<ZonedDateTime> source)
      Given a writable ZonedDateTime column source turn it into a writable long column source via reinterpretation if possible.
      Parameters:
      source - the source to turn into a long source
      Returns:
      the long source or null if it could not be reinterpreted
    • maybeConvertToPrimitive

      @NotNull public static @NotNull ColumnSource<?> maybeConvertToPrimitive(@NotNull @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
    • maybeConvertToWritablePrimitive

      @NotNull public static @NotNull WritableColumnSource<?> maybeConvertToWritablePrimitive(@NotNull @NotNull WritableColumnSource<?> 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, source converted to a writable primitive, otherwise source
    • maybeConvertToPrimitiveChunkType

      @NotNull public static @NotNull ChunkType maybeConvertToPrimitiveChunkType(@NotNull @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 extracting primitives from the source
    • maybeConvertToWritablePrimitiveChunkType

      @NotNull public static @NotNull ChunkType maybeConvertToWritablePrimitiveChunkType(@NotNull @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
    • maybeConvertToPrimitiveDataType

      @NotNull public static @NotNull Class<?> maybeConvertToPrimitiveDataType(@NotNull @NotNull Class<?> dataType)
      If dataType is something that we prefer to handle as a primitive, emit the appropriate data type to use, else return dataType.
      Parameters:
      dataType - The data type to examine
      Returns:
      the appropriate data type to use when extracting primitives from the source
    • convertToOriginalType

      @NotNull public static @NotNull ColumnSource<?> convertToOriginalType(@NotNull @NotNull ColumnSource<?> originalSource, @NotNull @NotNull ColumnSource<?> sourceToConvert)
      Reinterpret or box sourceToConvert back to its original type.
      Parameters:
      originalSource - The source that was reinterpreted to produce sourceToConvert, or a similarly-typed source for type information
      sourceToConvert - The source to convert
      Returns:
      reinterpret or box sourceToConvert back to the original type if possible
      Throws:
      UnsupportedOperationException - for unsupported conversions