io.deephaven.chunk.util.hashing.ByteToIntegerCastWithOffset 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 CharToIntegerCastWithOffset and run "./gradlew replicateHashing" to regenerate
//
// @formatter:off
package io.deephaven.chunk.util.hashing;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.ByteChunk;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.IntChunk;
import io.deephaven.chunk.WritableIntChunk;
/**
* Cast the values in the input chunk to an int and add the specified offset.
*
* @param the chunk's attribute
*/
public class ByteToIntegerCastWithOffset implements ToIntFunctor {
private final WritableIntChunk result;
private final int offset;
ByteToIntegerCastWithOffset(int size, int offset) {
result = WritableIntChunk.makeWritableChunk(size);
this.offset = offset;
}
@Override
public IntChunk extends T> apply(Chunk extends T> input) {
return castWithOffset(input.asByteChunk());
}
private IntChunk castWithOffset(ByteChunk extends T> input) {
for (int ii = 0; ii < input.size(); ++ii) {
result.set(ii, (int) input.get(ii) + offset);
}
result.setSize(input.size());
return result;
}
@Override
public void close() {
result.close();
}
}