use of com.facebook.presto.spi.block.ArrayBlock in project presto by prestodb.
the class ParquetReader method readArray.
private Block readArray(Type type, List<String> path, IntList elementOffsets) throws IOException {
List<Type> parameters = type.getTypeParameters();
checkArgument(parameters.size() == 1, "Arrays must have a single type parameter, found %d", parameters.size());
path.add(ARRAY_TYPE_NAME);
Type elementType = parameters.get(0);
Block block = readBlock(ARRAY_ELEMENT_NAME, elementType, path, elementOffsets);
path.remove(ARRAY_TYPE_NAME);
if (elementOffsets.isEmpty()) {
for (int i = 0; i < batchSize; i++) {
elementOffsets.add(0);
}
return RunLengthEncodedBlock.create(elementType, null, batchSize);
}
int[] offsets = new int[batchSize + 1];
for (int i = 1; i < offsets.length; i++) {
offsets[i] = offsets[i - 1] + elementOffsets.getInt(i - 1);
}
return new ArrayBlock(batchSize, new boolean[batchSize], offsets, block);
}
Aggregations