io.deephaven.engine.table.impl.util.cast.ByteToDoubleCast Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
/*
* ---------------------------------------------------------------------------------------------------------------------
* AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit CharToDoubleCast and regenerate
* ---------------------------------------------------------------------------------------------------------------------
*/
package io.deephaven.engine.table.impl.util.cast;
import io.deephaven.chunk.*;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.util.QueryConstants;
/**
* Cast the values in the input chunk to an int.
*/
public class ByteToDoubleCast implements ToDoubleCast {
private final WritableDoubleChunk result;
ByteToDoubleCast(int size) {
result = WritableDoubleChunk.makeWritableChunk(size);
}
@Override
public DoubleChunk extends T> cast(Chunk extends T> input) {
return cast(input.asByteChunk());
}
@SuppressWarnings("unchecked")
private DoubleChunk cast(ByteChunk input) {
castInto(input, result);
return result;
}
public static void castInto(ByteChunk extends T2> input, WritableDoubleChunk result) {
final int size = input.size();
for (int ii = 0; ii < size; ++ii) {
final byte value = input.get(ii);
if (value == QueryConstants.NULL_BYTE) {
result.set(ii, QueryConstants.NULL_DOUBLE);
} else {
result.set(ii, value);
}
}
result.setSize(input.size());
}
@Override
public void close() {
result.close();
}
}