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

io.deephaven.engine.table.impl.join.dupexpand.CharDupExpandKernel 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.join.dupexpand;

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

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

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

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

    public static void expandDuplicates(int expandedSize, WritableCharChunk 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