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

io.deephaven.engine.table.impl.sources.regioned.ColumnRegionDouble 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 ColumnRegionChar and regenerate
 * ---------------------------------------------------------------------------------------------------------------------
 */
package io.deephaven.engine.table.impl.sources.regioned;

import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.ChunkType;
import io.deephaven.chunk.WritableChunk;
import io.deephaven.engine.page.PagingContextHolder;
import io.deephaven.util.QueryConstants;
import io.deephaven.util.annotations.FinalDefault;
import org.jetbrains.annotations.NotNull;

/**
 * Column region interface for regions that support fetching primitive doubles.
 */
public interface ColumnRegionDouble extends ColumnRegion {

    /**
     * Get a single double from this region.
     *
     * @param elementIndex Element row key in the table's address space
     * @return The double value at the specified element row key
     */
    double getDouble(long elementIndex);

    /**
     * Get a single double from this region.
     *
     * @param context      A {@link PagingContextHolder} to enable resource caching where suitable, with current
     *                     region index pointing to this region
     * @param elementIndex Element row key in the table's address space
     * @return The double value at the specified element row key
     */
    default double getDouble(@NotNull final FillContext context, final long elementIndex) {
        return getDouble(elementIndex);
    }

    @Override
    @FinalDefault
    default ChunkType getChunkType() {
        return ChunkType.Double;
    }

    static  ColumnRegionDouble createNull(final long pageMask) {
        //noinspection unchecked
        return pageMask == Null.DEFAULT_INSTANCE.mask() ? Null.DEFAULT_INSTANCE : new Null(pageMask);
    }

    final class Null extends ColumnRegion.Null implements ColumnRegionDouble {
        @SuppressWarnings("rawtypes")
        private static final ColumnRegionDouble DEFAULT_INSTANCE = new ColumnRegionDouble.Null(RegionedColumnSourceBase.PARAMETERS.regionMask);

        private Null(final long pageMask) {
            super(pageMask);
        }

        @Override
        public double getDouble(final long elementIndex) {
            return QueryConstants.NULL_DOUBLE;
        }
    }

    final class Constant
            extends GenericColumnRegionBase
            implements ColumnRegionDouble, WithDefaultsForRepeatingValues {

        private final double value;

        public Constant(final long pageMask, final double value) {
            super(pageMask);
            this.value = value;
        }

        @Override
        public double getDouble(final long elementIndex) {
            return value;
        }

        @Override
        public void fillChunkAppend(@NotNull final FillContext context, @NotNull final WritableChunk destination, final int length) {
            final int offset = destination.size();
            destination.asWritableDoubleChunk().fillWithValue(offset, length, value);
            destination.setSize(offset + length);
        }
    }

    final class StaticPageStore
            extends RegionedPageStore.Static>
            implements ColumnRegionDouble {

        public StaticPageStore(@NotNull final Parameters parameters, @NotNull final ColumnRegionDouble[] regions) {
            super(parameters, regions);
        }

        @Override
        public void invalidate() {
            for(int ii = 0; ii < getRegionCount(); ii++) {
                getRegion(ii).invalidate();
            }
        }

        @Override
        public double getDouble(final long elementIndex) {
            return lookupRegion(elementIndex).getDouble(elementIndex);
        }

        @Override
        public double getDouble(@NotNull final FillContext context, final long elementIndex) {
            return lookupRegion(elementIndex).getDouble(context, elementIndex);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy