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

io.deephaven.engine.table.impl.util.unboxer.IntUnboxer Maven / Gradle / Ivy

There is a newer version: 0.36.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 CharUnboxer and regenerate
 * ---------------------------------------------------------------------------------------------------------------------
 */
package io.deephaven.engine.table.impl.util.unboxer;

import io.deephaven.chunk.*;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.util.type.TypeUtils;

class IntUnboxer implements ChunkUnboxer.UnboxerKernel {
    private final WritableIntChunk primitiveChunk;

    IntUnboxer(int capacity) {
        primitiveChunk = WritableIntChunk.makeWritableChunk(capacity);
    }

    @Override
    public void close() {
        primitiveChunk.close();
    }

    @Override
    public IntChunk unbox(ObjectChunk boxed) {
        unboxTo(boxed, primitiveChunk, 0, 0);
        primitiveChunk.setSize(boxed.size());
        return primitiveChunk;
    }

    @Override
    public void unboxTo(ObjectChunk boxed, WritableChunk primitives, int sourceOffset, int destOffset) {
        unboxTo(boxed, primitives.asWritableIntChunk(), sourceOffset, destOffset);
    }

    public static void unboxTo(ObjectChunk boxed, WritableIntChunk primitives, int sourceOffset, int destOffset) {
        final ObjectChunk intChunk = boxed.asObjectChunk();
        for (int ii = 0; ii < boxed.size(); ++ii) {
            primitives.set(ii + destOffset, TypeUtils.unbox(intChunk.get(ii + sourceOffset)));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy