All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.engine.table.impl.sources.UnboxedLongBackedColumnSource Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
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