use of org.apache.flink.streaming.api.functions.sink.filesystem.bucketassigners.BasePathBucketAssigner in project flink by apache.
the class DataStreamCsvITCase method testCustomBulkWriter.
@Test
public void testCustomBulkWriter() throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
// fromCollection is not bounded, using fromSequence instead
// needs to be Serializable
final List<CityPojo> pojosList = Arrays.asList(POJOS);
final DataStream<Integer> sequence = env.fromSequence(0, POJOS.length - 1).map(Long::intValue);
final DataStream<CityPojo> stream = sequence.map(pojosList::get).returns(CityPojo.class);
FileSink<CityPojo> sink = FileSink.forBulkFormat(new Path(outDir.toURI()), factoryForPojo(CityPojo.class)).withBucketAssigner(new BasePathBucketAssigner<>()).build();
stream.sinkTo(sink);
env.execute();
String[] result = getResultsFromSinkFiles(outDir);
assertThat(result).containsExactlyInAnyOrder(CSV_LINES);
}
Aggregations