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

io.deephaven.engine.table.impl.sources.regioned.ColumnRegionShort 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 shorts.
 */
public interface ColumnRegionShort extends ColumnRegion {

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

    /**
     * Get a single short 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 short value at the specified element row key
     */
    default short getShort(@NotNull final FillContext context, final long elementIndex) {
        return getShort(elementIndex);
    }

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

    static  ColumnRegionShort 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 ColumnRegionShort {
        @SuppressWarnings("rawtypes")
        private static final ColumnRegionShort DEFAULT_INSTANCE = new ColumnRegionShort.Null(RegionedColumnSourceBase.PARAMETERS.regionMask);

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

        @Override
        public short getShort(final long elementIndex) {
            return QueryConstants.NULL_SHORT;
        }
    }

    final class Constant
            extends GenericColumnRegionBase
            implements ColumnRegionShort, WithDefaultsForRepeatingValues {

        private final short value;

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

        @Override
        public short getShort(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.asWritableShortChunk().fillWithValue(offset, length, value);
            destination.setSize(offset + length);
        }
    }

    final class StaticPageStore
            extends RegionedPageStore.Static>
            implements ColumnRegionShort {

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

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

        @Override
        public short getShort(final long elementIndex) {
            return lookupRegion(elementIndex).getShort(elementIndex);
        }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy