io.deephaven.chunk.util.hashing.CharToLongCast Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-chunk Show documentation
Show all versions of deephaven-engine-chunk Show documentation
Engine Chunks: Array-like data structures for dense, efficient data movement
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 extends T2> input, WritableLongChunk super T2> 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();
}
}