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

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

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