public static Block fromElementBlock(int positionCount, Optional<boolean[]> valueIsNull, int[] arrayOffset, Block values)
{
validateConstructorArguments(0, positionCount, valueIsNull.orElse(null), arrayOffset, values);
for (int i = 0; i < positionCount; i++) {
int offset = arrayOffset[i];
int length = arrayOffset[i + 1] - offset;
if (length < 0) {
throw new IllegalArgumentException(format("Offset is not monotonically ascending. offsets[%s]=%s, offsets[%s]=%s", i, arrayOffset[i], i + 1, arrayOffset[i + 1]));
}
if (valueIsNull.isPresent() && valueIsNull.get()[i] && length != 0) {
throw new IllegalArgumentException("A null array must have zero entries");
}
}
return new ArrayBlock(0, positionCount, valueIsNull.orElse(null), arrayOffset, values);
}