use of com.facebook.presto.block.BlockAssertions.Encoding in project presto by prestodb.
the class TestBlockEncodingBuffers method buildMapBlockStatus.
private BlockStatus buildMapBlockStatus(MapType mapType, int positionCount, boolean isView, Optional<boolean[]> isNull, int[] offsets, float primitiveNullRate, float nestedNullRate, List<Encoding> wrappings) {
BlockStatus blockStatus;
BlockStatus keyBlockStatus = buildBlockStatusWithType(mapType.getKeyType(), offsets[positionCount], isView, 0.0f, 0.0f, wrappings);
BlockStatus valueBlockStatus = buildBlockStatusWithType(mapType.getValueType(), offsets[positionCount], isView, primitiveNullRate, nestedNullRate, wrappings);
int[] expectedKeySizes = keyBlockStatus.expectedRowSizes;
int[] expectedValueSizes = valueBlockStatus.expectedRowSizes;
// Use expectedKeySizes for the total size for both key and values
Arrays.setAll(expectedKeySizes, i -> expectedKeySizes[i] + expectedValueSizes[i]);
int[] expectedRowSizes = IntStream.range(0, positionCount).map(i -> MapBlockEncodingBuffer.POSITION_SIZE + Arrays.stream(expectedKeySizes, offsets[i], offsets[i + 1]).sum()).toArray();
Type keyType = mapType.getKeyType();
blockStatus = new BlockStatus(fromKeyValueBlock(positionCount, isNull, offsets, keyBlockStatus.block, valueBlockStatus.block), expectedRowSizes);
return blockStatus;
}
Aggregations