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

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

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
/*
 * ---------------------------------------------------------------------------------------------------------------------
 * AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit UngroupedCharVectorColumnSource and regenerate
 * ---------------------------------------------------------------------------------------------------------------------
 */
package io.deephaven.engine.table.impl.sources;

import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults;
import io.deephaven.vector.LongVector;

import static io.deephaven.util.QueryConstants.NULL_LONG;

public class UngroupedLongVectorColumnSource extends UngroupedColumnSource implements MutableColumnSourceGetDefaults.ForLong {
    private ColumnSource innerSource;
    private final boolean isUngroupable;

    @Override
    public Class getComponentType() {
        return null;
    }


    public UngroupedLongVectorColumnSource(ColumnSource innerSource) {
        super(Long.class);
        this.innerSource = innerSource;
        this.isUngroupable = innerSource instanceof UngroupableColumnSource && ((UngroupableColumnSource)innerSource).isUngroupable();
    }

    @Override
    public Long get(long rowKey) {
        if (rowKey < 0) {
            return null;
        }
        long segment = rowKey >>base;
        int offset = (int) (rowKey & ((1<>base;
        int offset = (int) (rowKey & ((1<> getPrevBase();
        int offset = (int) (rowKey & ((1<< getPrevBase()) - 1));
        final Long result;
        if (isUngroupable) {
            result = (Long)((UngroupableColumnSource)innerSource).getUngroupedPrev(segment, offset);
            if (result == null) {
                return null;
            }
        } else {
            final LongVector segmentArray = innerSource.getPrev(segment);
            result = segmentArray == null ? NULL_LONG : segmentArray.get(offset);
        }

        return (result == NULL_LONG ? null : result);
    }

    @Override
    public long getPrevLong(long rowKey) {
        if (rowKey < 0) {
            return NULL_LONG;
        }

        long segment = rowKey >> getPrevBase();
        int offset = (int) (rowKey & ((1<< getPrevBase()) - 1));

        if (isUngroupable) {
            return ((UngroupableColumnSource)innerSource).getUngroupedPrevLong(segment, offset);
        }

        final LongVector segmentArray = innerSource.getPrev(segment);
        return segmentArray == null ? NULL_LONG : segmentArray.get(offset);
    }

    @Override
    public boolean isImmutable() {
        return false;
    }

    @Override
    public boolean isStateless() {
        return innerSource.isStateless();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy