/** * Create an array block directly without per element validations. */ static ArrayBlock createArrayBlockInternal(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values) { validateConstructorArguments(arrayOffset, positionCount, valueIsNull, offsets, values); return new ArrayBlock(arrayOffset, positionCount, valueIsNull, offsets, values); }
/** * Create an array block directly from columnar nulls, values, and offsets into the values. * A null array must have no entries. */ public static Block fromElementBlock(int positionCount, Optional<boolean[]> valueIsNull, int[] arrayOffset, Block values) { validateConstructorArguments(0, positionCount, valueIsNull.orElse(null), arrayOffset, values); // for performance reasons per element checks are only performed on the public construction 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); }
/** * Create an array block directly without per element validations. */ static ArrayBlock createArrayBlockInternal(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values) { validateConstructorArguments(arrayOffset, positionCount, valueIsNull, offsets, values); return new ArrayBlock(arrayOffset, positionCount, valueIsNull, offsets, values); }
/** * Create an array block directly from columnar nulls, values, and offsets into the values. * A null array must have no entries. */ public static Block fromElementBlock(int positionCount, Optional<boolean[]> valueIsNull, int[] arrayOffset, Block values) { validateConstructorArguments(0, positionCount, valueIsNull.orElse(null), arrayOffset, values); // for performance reasons per element checks are only performed on the public construction 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); }
ArrayBlock arrayBlock = new ArrayBlock(interleavedBlock, Slices.wrappedIntArray(offsets), 0, Slices.wrappedBooleanArray(nullVector));
elements = elementType.createBlockBuilder(new BlockBuilderStatus(), 0).build(); ArrayBlock arrayBlock = new ArrayBlock(elements, Slices.wrappedIntArray(offsets), 0, Slices.wrappedBooleanArray(nullVector));
lengths[i] = lengths[i - 1] + (lengths[i] * 2); ArrayBlock arrayBlock = new ArrayBlock(keyValueBlock, Slices.wrappedIntArray(lengths), 0, Slices.wrappedBooleanArray(nullVector));