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

io.deephaven.engine.table.impl.join.dupexpand.ObjectDupExpandKernel 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 CharDupExpandKernel and regenerate
 * ---------------------------------------------------------------------------------------------------------------------
 */
package io.deephaven.engine.table.impl.join.dupexpand;

import java.util.Objects;

import io.deephaven.chunk.*;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.attributes.ChunkLengths;

public class ObjectDupExpandKernel implements DupExpandKernel {
    public static final ObjectDupExpandKernel INSTANCE = new ObjectDupExpandKernel();

    private ObjectDupExpandKernel() {} // use through the instance

    @Override
    public void expandDuplicates(int expandedSize, WritableChunk chunkToExpand, IntChunk keyRunLengths) {
        expandDuplicates(expandedSize, chunkToExpand.asWritableObjectChunk(), keyRunLengths);
    }

    public static void expandDuplicates(int expandedSize, WritableObjectChunk chunkToExpand, IntChunk keyRunLengths) {
        if (expandedSize == 0) {
            return;
        }

        int wpos = expandedSize;
        int rpos = chunkToExpand.size() - 1;
        chunkToExpand.setSize(expandedSize);

        for (; rpos >= 0; --rpos) {
            final int len = keyRunLengths.get(rpos);
            chunkToExpand.fillWithValue(wpos - len, len, chunkToExpand.get(rpos));
            wpos -= len;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy