use of com.facebook.presto.common.io.OutputStreamDataSink in project presto by prestodb.
the class TestStructBatchStreamReader method write.
private void write(TempFile tempFile, Type writerType, List<String> data) throws IOException {
OrcWriter writer = new OrcWriter(new OutputStreamDataSink(new FileOutputStream(tempFile.getFile())), ImmutableList.of(STRUCT_COL_NAME), ImmutableList.of(writerType), ORC, NONE, Optional.empty(), NO_ENCRYPTION, OrcWriterOptions.builder().withFlushPolicy(DefaultOrcWriterFlushPolicy.builder().withStripeMinSize(new DataSize(0, MEGABYTE)).withStripeMaxSize(new DataSize(32, MEGABYTE)).withStripeMaxRowCount(ORC_STRIPE_SIZE).build()).withRowGroupMaxRowCount(ORC_ROW_GROUP_SIZE).withDictionaryMaxMemory(new DataSize(32, MEGABYTE)).build(), ImmutableMap.of(), HIVE_STORAGE_TIME_ZONE, true, BOTH, new OrcWriterStats());
// write down some data with unsorted streams
Block[] fieldBlocks = new Block[data.size()];
int entries = 10;
boolean[] rowIsNull = new boolean[entries];
Arrays.fill(rowIsNull, false);
BlockBuilder blockBuilder = TEST_DATA_TYPE.createBlockBuilder(null, entries);
for (int i = 0; i < data.size(); i++) {
byte[] bytes = data.get(i).getBytes();
for (int j = 0; j < entries; j++) {
blockBuilder.writeBytes(Slices.wrappedBuffer(bytes), 0, bytes.length);
blockBuilder.closeEntry();
}
fieldBlocks[i] = blockBuilder.build();
blockBuilder = blockBuilder.newBlockBuilderLike(null);
}
Block rowBlock = RowBlock.fromFieldBlocks(rowIsNull.length, Optional.of(rowIsNull), fieldBlocks);
writer.write(new Page(rowBlock));
writer.close();
}
Aggregations