Class ReinterpretUtils
java.lang.Object
io.deephaven.engine.table.impl.sources.ReinterpretUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ColumnSource<Byte>
booleanToByteSource
(@NotNull ColumnSource<Boolean> source) Given aBoolean
column source turn it into abyte
column source, either via reinterpretation or wrapping.static @NotNull ColumnSource<Boolean>
byteToBooleanSource
(@NotNull ColumnSource<Byte> source) Given abyte
column source turn it into aBoolean
column source, either via reinterpretation or wrapping.static @NotNull ColumnSource<?>
convertToOriginalType
(@NotNull ColumnSource<?> originalSource, @NotNull ColumnSource<?> sourceToConvert) Reinterpret or boxsourceToConvert
back to its original type.static @NotNull ColumnSource<Long>
instantToLongSource
(@NotNull ColumnSource<Instant> source) Given anInstant
column source turn it into along
column source, either via reinterpretation or wrapping.static @NotNull ColumnSource<Instant>
longToInstantSource
(@NotNull ColumnSource<Long> source) Given along
column source turn it into anInstant
column source, either via reinterpretation or wrapping.static ColumnSource<ZonedDateTime>
longToZonedDateTimeSource
(@NotNull ColumnSource<Long> source, @NotNull ZoneId wrapperTimeZone) Given along
column source turn it into aZonedDateTime
column source, either via reinterpretation or wrapping.static @NotNull ColumnSource<?>
maybeConvertToPrimitive
(@NotNull ColumnSource<?> source) If source is something that we prefer to handle as a primitive, do the appropriate conversion.static @NotNull ColumnSource<?>[]
maybeConvertToPrimitive
(@NotNull ColumnSource<?>[] sources) Convert each source insources
to a primitive if possible.static @NotNull ChunkType
maybeConvertToPrimitiveChunkType
(@NotNull Class<?> dataType) IfdataType
is something that we prefer to handle as a primitive, emit the appropriateChunkType
, else the normal ChunkType for the data type.static @NotNull Class<?>
maybeConvertToPrimitiveDataType
(@NotNull Class<?> dataType) IfdataType
is something that we prefer to handle as a primitive, emit the appropriatedata type to use
, else returndataType
.static @NotNull WritableColumnSource<?>
maybeConvertToWritablePrimitive
(@NotNull WritableColumnSource<?> source) Ifsource
is something that we prefer to handle as a primitive, do the appropriate conversion.static @NotNull ChunkType
maybeConvertToWritablePrimitiveChunkType
(@NotNull Class<?> dataType) IfdataType
is something that we prefer to handle as a primitive, emit the appropriateChunkType
, else the normal ChunkType for the data type.static @Nullable WritableColumnSource<Byte>
writableBooleanToByteSource
(@NotNull WritableColumnSource<Boolean> source) Given a writableBoolean
column source turn it into a writablebyte
column source via reinterpretation if possible.static @Nullable WritableColumnSource<Long>
writableInstantToLongSource
(@NotNull WritableColumnSource<Instant> source) Given a writableInstant
column source turn it into a writablelong
column source via reinterpretation if possible.static @Nullable WritableColumnSource<Long>
writableZonedDateTimeToLongSource
(@NotNull WritableColumnSource<ZonedDateTime> source) Given a writableZonedDateTime
column source turn it into a writablelong
column source via reinterpretation if possible.static @NotNull ColumnSource<Long>
zonedDateTimeToLongSource
(@NotNull ColumnSource<ZonedDateTime> source) Given aZonedDateTime
column source turn it into along
column source, either via reinterpretation or wrapping.
-
Constructor Details
-
ReinterpretUtils
public ReinterpretUtils()
-
-
Method Details
-
byteToBooleanSource
@NotNull public static @NotNull ColumnSource<Boolean> byteToBooleanSource(@NotNull @NotNull ColumnSource<Byte> source) Given abyte
column source turn it into aBoolean
column source, either via reinterpretation or wrapping. -
booleanToByteSource
@NotNull public static @NotNull ColumnSource<Byte> booleanToByteSource(@NotNull @NotNull ColumnSource<Boolean> source) Given aBoolean
column source turn it into abyte
column source, either via reinterpretation or wrapping.- Parameters:
source
- the source to turn into abyte
source- Returns:
- the
byte
source
-
writableBooleanToByteSource
@Nullable public static @Nullable WritableColumnSource<Byte> writableBooleanToByteSource(@NotNull @NotNull WritableColumnSource<Boolean> source) Given a writableBoolean
column source turn it into a writablebyte
column source via reinterpretation if possible.- Parameters:
source
- the source to turn into abyte
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 along
column source turn it into anInstant
column source, either via reinterpretation or wrapping.- Parameters:
source
- the source to turn into anInstant
source- Returns:
- the
long
source
-
instantToLongSource
@NotNull public static @NotNull ColumnSource<Long> instantToLongSource(@NotNull @NotNull ColumnSource<Instant> source) Given anInstant
column source turn it into along
column source, either via reinterpretation or wrapping.- Parameters:
source
- the source to turn into along
source- Returns:
- the
long
source
-
writableInstantToLongSource
@Nullable public static @Nullable WritableColumnSource<Long> writableInstantToLongSource(@NotNull @NotNull WritableColumnSource<Instant> source) Given a writableInstant
column source turn it into a writablelong
column source via reinterpretation if possible.- Parameters:
source
- the source to turn into along
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 along
column source turn it into aZonedDateTime
column source, either via reinterpretation or wrapping.- Parameters:
source
- the source to turn into aZonedDateTime
sourcewrapperTimeZone
- theZoneId
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 aZonedDateTime
column source turn it into along
column source, either via reinterpretation or wrapping.- Parameters:
source
- the source to turn into along
source- Returns:
- the
long
source
-
writableZonedDateTimeToLongSource
@Nullable public static @Nullable WritableColumnSource<Long> writableZonedDateTimeToLongSource(@NotNull @NotNull WritableColumnSource<ZonedDateTime> source) Given a writableZonedDateTime
column source turn it into a writablelong
column source via reinterpretation if possible.- Parameters:
source
- the source to turn into along
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
-
maybeConvertToPrimitive
@NotNull public static @NotNull ColumnSource<?>[] maybeConvertToPrimitive(@NotNull @NotNull ColumnSource<?>[] sources) Convert each source insources
to a primitive if possible.- Parameters:
sources
- An array of the sources to potentially convert- Returns:
- The primitive sources for each source in
sources
-
maybeConvertToWritablePrimitive
@NotNull public static @NotNull WritableColumnSource<?> maybeConvertToWritablePrimitive(@NotNull @NotNull WritableColumnSource<?> source) Ifsource
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, otherwisesource
-
maybeConvertToPrimitiveChunkType
@NotNull public static @NotNull ChunkType maybeConvertToPrimitiveChunkType(@NotNull @NotNull Class<?> dataType) IfdataType
is something that we prefer to handle as a primitive, emit the appropriateChunkType
, else the normal ChunkType for the data type. -
maybeConvertToWritablePrimitiveChunkType
@NotNull public static @NotNull ChunkType maybeConvertToWritablePrimitiveChunkType(@NotNull @NotNull Class<?> dataType) IfdataType
is something that we prefer to handle as a primitive, emit the appropriateChunkType
, else the normal ChunkType for the data type. -
maybeConvertToPrimitiveDataType
@NotNull public static @NotNull Class<?> maybeConvertToPrimitiveDataType(@NotNull @NotNull Class<?> dataType) IfdataType
is something that we prefer to handle as a primitive, emit the appropriatedata type to use
, else returndataType
.- 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 boxsourceToConvert
back to its original type.- Parameters:
originalSource
- The source that was reinterpreted to producesourceToConvert
, or a similarly-typed source for type informationsourceToConvert
- The source to convert- Returns:
- reinterpret or box
sourceToConvert
back to the original type if possible - Throws:
UnsupportedOperationException
- for unsupported conversions
-