io.deephaven.chunk.util.hashing.ShortToLongCastWithOffset 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
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit CharToLongCastWithOffset and run "./gradlew replicateHashing" to regenerate
//
// @formatter:off
package io.deephaven.chunk.util.hashing;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.ShortChunk;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.LongChunk;
import io.deephaven.chunk.WritableLongChunk;
/**
* Cast the values in the input chunk to an long and add the specified offset.
*
* @param the chunk's attribute
*/
public class ShortToLongCastWithOffset implements ToLongFunctor {
private final WritableLongChunk result;
private final long offset;
ShortToLongCastWithOffset(int size, long offset) {
result = WritableLongChunk.makeWritableChunk(size);
this.offset = offset;
}
@Override
public LongChunk apply(Chunk input) {
return castWithOffset(input.asShortChunk());
}
private LongChunk castWithOffset(ShortChunk input) {
castInto(input, result, offset);
return result;
}
public static void castInto(ShortChunk input, WritableLongChunk result, long offset) {
for (int ii = 0; ii < input.size(); ++ii) {
result.set(ii, (long) input.get(ii) + offset);
}
result.setSize(input.size());
}
@Override
public void close() {
result.close();
}
}