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

io.deephaven.chunk.util.hashing.CharToLongCast Maven / Gradle / Ivy

The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.chunk.util.hashing;

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

/**
 * Cast the values in the input chunk to a long.
 *
 * @param  the chunk's attribute
 */
public class CharToLongCast implements ToLongFunctor {
    private final WritableLongChunk result;

    CharToLongCast(int size) {
        result = WritableLongChunk.makeWritableChunk(size);
    }

    @Override
    public LongChunk apply(Chunk input) {
        return cast(input.asCharChunk());
    }

    private LongChunk cast(CharChunk input) {
        castInto(input, result);
        return result;
    }

    public static  void castInto(CharChunk input, WritableLongChunk result) {
        for (int ii = 0; ii < input.size(); ++ii) {
            result.set(ii, (long) input.get(ii));
        }
        result.setSize(input.size());
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy