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

io.deephaven.engine.table.impl.select.setinclusion.ObjectSetInclusionKernel 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.select.setinclusion;

import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.ObjectChunk;
import io.deephaven.chunk.WritableBooleanChunk;
import io.deephaven.chunk.attributes.Values;

import java.util.Collection;

public class ObjectSetInclusionKernel implements SetInclusionKernel {
    private final Collection liveValues;
    private final boolean inclusion;

    public ObjectSetInclusionKernel(Collection liveValues, boolean inclusion) {
        this.liveValues = liveValues;
        this.inclusion = inclusion;
    }

    @Override
    public void matchValues(Chunk values, WritableBooleanChunk matches) {
        matchValues(values.asObjectChunk(), matches);
    }

    private void matchValues(ObjectChunk values, WritableBooleanChunk matches) {
        for (int ii = 0; ii < values.size(); ++ii) {
            matches.set(ii, liveValues.contains(values.get(ii)) == inclusion);
        }
        matches.setSize(values.size());
    }
}