io.deephaven.engine.table.impl.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
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.engine.table.impl;
import io.deephaven.engine.table.ColumnSource;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
/**
* Reinterpret result for many {@link ColumnSource} implementations that internally represent time values, such as
* {@link Instant}, 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) {
return alternateDataType == alternateColumnSource.getType()
|| alternateColumnSource.allowsReinterpret(alternateDataType);
}
@Override
public ColumnSource doReinterpret(
@NotNull final Class alternateDataType) throws IllegalArgumentException {
if (alternateDataType == alternateColumnSource.getType()) {
// noinspection unchecked
return (ColumnSource) alternateColumnSource;
}
return alternateColumnSource.reinterpret(alternateDataType);
}
@Override
public boolean isStateless() {
return alternateColumnSource.isStateless();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy