io.deephaven.engine.table.impl.sources.UnboxedLongBackedColumnSource 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
package io.deephaven.engine.table.impl.sources;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.impl.AbstractColumnSource;
import io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
/**
* Reinterpret result for many {@link ColumnSource} implementations that internally represent {@link Instant} values
* as {@code long} values.
*/
public class UnboxedLongBackedColumnSource extends AbstractColumnSource implements MutableColumnSourceGetDefaults.ForLong {
private final ColumnSource alternateColumnSource;
public UnboxedLongBackedColumnSource(ColumnSource alternateColumnSource) {
super(long.class);
this.alternateColumnSource = alternateColumnSource;
}
@Override
public long getLong(long rowKey) {
return alternateColumnSource.getLong(rowKey);
}
@Override
public long getPrevLong(long rowKey) {
return alternateColumnSource.getPrevLong(rowKey);
}
@Override
public boolean isImmutable() {
return alternateColumnSource.isImmutable();
}
@Override
public boolean allowsReinterpret(
@NotNull final Class alternateDataType) {
if (alternateDataType == alternateColumnSource.getType()) {
// this is a trivial return conversion
return true;
}
return alternateColumnSource.allowsReinterpret(alternateDataType);
}
@Override
public ColumnSource doReinterpret(
@NotNull final Class alternateDataType) throws IllegalArgumentException {
if (alternateDataType == alternateColumnSource.getType()) {
// this is a trivial return conversion
//noinspection unchecked
return (ColumnSource) alternateColumnSource;
}
return alternateColumnSource.reinterpret(alternateDataType);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy