io.deephaven.engine.table.impl.sources.regioned.RegionedColumnSourceLong Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
/*
* ---------------------------------------------------------------------------------------------------------------------
* AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit RegionedColumnSourceChar and regenerate
* ---------------------------------------------------------------------------------------------------------------------
*/
package io.deephaven.engine.table.impl.sources.regioned;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.impl.sources.LongAsLocalDateColumnSource;
import io.deephaven.engine.table.impl.sources.LongAsLocalTimeColumnSource;
import io.deephaven.engine.table.impl.sources.ConvertibleTimeSource;
import io.deephaven.engine.rowset.RowSequence;
import io.deephaven.engine.table.ColumnDefinition;
import io.deephaven.engine.table.impl.locations.ColumnLocation;
import io.deephaven.engine.table.impl.locations.TableDataException;
import io.deephaven.engine.table.impl.locations.TableLocationKey;
import io.deephaven.engine.table.impl.ColumnSourceGetDefaults;
import io.deephaven.chunk.attributes.Values;
import org.jetbrains.annotations.NotNull;
import static io.deephaven.util.type.TypeUtils.unbox;
/**
* Regioned column source implementation for columns of longs.
*/
abstract class RegionedColumnSourceLong
extends RegionedColumnSourceArray>
implements ColumnSourceGetDefaults.ForLong , ConvertibleTimeSource {
RegionedColumnSourceLong(@NotNull final ColumnRegionLong nullRegion,
@NotNull final MakeDeferred> makeDeferred) {
super(nullRegion, long.class, makeDeferred);
}
@Override
public long getLong(final long rowKey) {
return (rowKey == RowSequence.NULL_ROW_KEY ? getNullRegion() : lookupRegion(rowKey)).getLong(rowKey);
}
interface MakeRegionDefault extends MakeRegion> {
@Override
default ColumnRegionLong makeRegion(@NotNull final ColumnDefinition> columnDefinition,
@NotNull final ColumnLocation columnLocation,
final int regionIndex) {
if (columnLocation.exists()) {
return columnLocation.makeColumnRegionLong(columnDefinition);
}
return null;
}
}
// region reinterpretation
@Override
public boolean allowsReinterpret(@NotNull Class alternateDataType) {
if(super.allowsReinterpret(alternateDataType)) {
return true;
}
return alternateDataType == Instant.class;
}
@SuppressWarnings("unchecked")
@Override
protected ColumnSource doReinterpret(@NotNull Class alternateDataType) {
if(alternateDataType == Instant.class) {
return (ColumnSource) toInstant();
}
return super.doReinterpret(alternateDataType);
}
@Override
public boolean supportsTimeConversion() {
return true;
}
public ColumnSource toInstant() {
//noinspection unchecked
return new RegionedColumnSourceInstant((RegionedColumnSourceLong) this);
}
@Override
public ColumnSource toZonedDateTime(ZoneId zone) {
//noinspection unchecked
return new RegionedColumnSourceZonedDateTime(zone, (RegionedColumnSourceLong) this);
}
@Override
public ColumnSource toLocalTime(ZoneId zone) {
return new LongAsLocalTimeColumnSource(this, zone);
}
@Override
public ColumnSource toLocalDate(ZoneId zone) {
return new LongAsLocalDateColumnSource(this, zone);
}
@Override
public ColumnSource toEpochNano() {
return this;
}
// endregion reinterpretation
static final class AsValues extends RegionedColumnSourceLong implements MakeRegionDefault {
AsValues() {
super(ColumnRegionLong.createNull(PARAMETERS.regionMask), DeferredColumnRegionLong::new);
}
}
static final class Partitioning extends RegionedColumnSourceLong {
Partitioning() {
super(ColumnRegionLong.createNull(PARAMETERS.regionMask),
(pm, rs) -> rs.get() // No need to interpose a deferred region in this case
);
}
@Override
public ColumnRegionLong makeRegion(@NotNull final ColumnDefinition> columnDefinition,
@NotNull final ColumnLocation columnLocation,
final int regionIndex) {
final TableLocationKey locationKey = columnLocation.getTableLocation().getKey();
final Object partitioningColumnValue = locationKey.getPartitionValue(columnDefinition.getName());
if (partitioningColumnValue != null && !Long.class.isAssignableFrom(partitioningColumnValue.getClass())) {
throw new TableDataException("Unexpected partitioning column value type for " + columnDefinition.getName()
+ ": " + partitioningColumnValue + " is not a Long at location " + locationKey);
}
return new ColumnRegionLong.Constant<>(regionMask(), unbox((Long) partitioningColumnValue));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy