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

io.deephaven.engine.table.impl.by.alternatingcolumnsource.AlternatingFillContextWithUnordered 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.by.alternatingcolumnsource;

import io.deephaven.chunk.ResettableWritableChunk;
import io.deephaven.chunk.WritableChunk;
import io.deephaven.chunk.WritableLongChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.engine.rowset.chunkattributes.RowKeys;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.table.SharedContext;
import io.deephaven.engine.table.impl.sources.FillUnordered;
import org.jetbrains.annotations.Nullable;

class AlternatingFillContextWithUnordered extends BaseAlternatingFillContext {
    final WritableLongChunk innerKeys;
    final WritableChunk innerValues;
    final ResettableWritableChunk innerSlice;
    final AlternatingColumnSourceUnorderedMergeKernel mergeKernel;

    AlternatingFillContextWithUnordered(@Nullable final ColumnSource mainSource,
            @Nullable final ColumnSource alternateSource,
            final int chunkCapacity,
            final SharedContext sharedContext) {
        super(mainSource, alternateSource, chunkCapacity, sharedContext);
        if ((mainSource == null || FillUnordered.providesFillUnordered(mainSource))
                && (alternateSource == null || FillUnordered.providesFillUnordered(alternateSource))) {
            innerKeys = alternateSource != null ? WritableLongChunk.makeWritableChunk(chunkCapacity) : null;
            if (mainSource != null && alternateSource != null) {
                innerSlice = mainSource.getChunkType().makeResettableWritableChunk();
                innerValues = mainSource.getChunkType().makeWritableChunk(chunkCapacity);
                mergeKernel = AlternatingColumnSourceUnorderedMergeKernel.getInstance(mainSource.getChunkType());
            } else {
                innerSlice = null;
                innerValues = null;
                mergeKernel = null;
            }
        } else {
            innerKeys = null;
            innerSlice = null;
            innerValues = null;
            mergeKernel = null;
        }
    }

    @Override
    public void close() {
        super.close();
        if (innerKeys != null) {
            innerKeys.close();
        }
        if (innerSlice != null) {
            innerSlice.close();
            innerValues.close();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy