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

io.deephaven.engine.table.impl.sources.regioned.RegionedColumnSourceBoolean 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.sources.regioned;

import io.deephaven.chunk.attributes.Values;
import io.deephaven.util.BooleanUtils;
import io.deephaven.engine.table.impl.ColumnSourceGetDefaults;
import io.deephaven.chunk.*;
import io.deephaven.engine.rowset.RowSequence;
import org.jetbrains.annotations.NotNull;

/**
 * Regioned column source implementation for columns of Booleans.
 */
final class RegionedColumnSourceBoolean
        extends RegionedColumnSourceReferencing>
        implements ColumnSourceGetDefaults.ForBoolean {

    public RegionedColumnSourceBoolean() {
        this(new RegionedColumnSourceByte.AsValues());
    }

    public RegionedColumnSourceBoolean(@NotNull final RegionedColumnSourceByte inner) {
        super(ColumnRegionByte.createNull(PARAMETERS.regionMask), Boolean.class, inner);
    }

    @Override
    public void convertRegion(
            @NotNull final WritableChunk destination,
            @NotNull final Chunk source,
            @NotNull final RowSequence rowSequence) {
        WritableObjectChunk objectChunk = destination.asWritableObjectChunk();
        ByteChunk byteChunk = source.asByteChunk();

        final int size = destination.size();
        final int length = byteChunk.size();

        for (int i = 0; i < length; ++i) {
            objectChunk.set(size + i, BooleanUtils.byteAsBoolean(byteChunk.get(i)));
        }
        objectChunk.setSize(size + length);
    }

    @Override
    public Boolean get(long rowKey) {
        return rowKey == RowSequence.NULL_ROW_KEY ? null :
                BooleanUtils.byteAsBoolean(getNativeSource().lookupRegion(rowKey).getByte(rowKey));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy