use of com.facebook.presto.parquet.writer.ParquetWriter in project presto by prestodb.
the class ParquetTester method writeParquetFileFromPresto.
public static void writeParquetFileFromPresto(File outputFile, List<Type> types, List<String> columnNames, Iterator<?>[] values, int size, CompressionCodecName compressionCodecName) throws Exception {
checkArgument(types.size() == columnNames.size() && types.size() == values.length);
ParquetWriter writer = new ParquetWriter(new FileOutputStream(outputFile), columnNames, types, ParquetWriterOptions.builder().setMaxPageSize(DataSize.succinctBytes(100)).setMaxBlockSize(DataSize.succinctBytes(100000)).build(), compressionCodecName.getHadoopCompressionCodecClassName());
PageBuilder pageBuilder = new PageBuilder(types);
for (int i = 0; i < types.size(); ++i) {
Type type = types.get(i);
Iterator<?> iterator = values[i];
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i);
for (int j = 0; j < size; ++j) {
checkState(iterator.hasNext());
Object value = iterator.next();
writeValue(type, blockBuilder, value);
}
}
pageBuilder.declarePositions(size);
writer.write(pageBuilder.build());
writer.close();
}
Aggregations