this.testBlockWithNulls = createAlternatingNullsBlock(testBlock);
}
private Block createAlternatingNullsBlock(Block testBlock)
{
BlockBuilder nullsBlockBuilder = type.createBlockBuilder(new BlockBuilderStatus());
for (int position = 0; position < testBlock.getPositionCount(); position++) {
if (type.getJavaType() == void.class) {
nullsBlockBuilder.appendNull();
}
else if (type.getJavaType() == boolean.class) {
type.writeBoolean(nullsBlockBuilder, type.getBoolean(testBlock, position));
}
else if (type.getJavaType() == long.class) {
type.writeLong(nullsBlockBuilder, type.getLong(testBlock, position));
}
else if (type.getJavaType() == double.class) {
type.writeDouble(nullsBlockBuilder, type.getDouble(testBlock, position));
}
else if (type.getJavaType() == Slice.class) {
Slice slice = type.getSlice(testBlock, position);
type.writeSlice(nullsBlockBuilder, slice, 0, slice.length());
}
else {
throw new RuntimeException("Unsupported Java type " + type.getJavaType());
}
nullsBlockBuilder.appendNull();
}
return nullsBlockBuilder.build();
}