0

When an execute job in batch mode in flink the fileSink generates multiple files by the parallel number but I want only the output in one file without changing the parallel number How can I do that ?

put parallel in 5 and get only one file in the output of FileSink.

 OutputFileConfig config = OutputFileConfig
 .builder()
 .withPartPrefix("prefix")
 .withPartSuffix(".txt")
 .build();
 final FileSink<String> sinkfile = FileSink
 .forRowFormat(new Path("src/main/resources/output"), new SimpleStringEncoder<String>("UTF-8"))
 .withBucketAssigner(new BasePathBucketAssigner<>())
 .withOutputFileConfig(config)
 .build();
asked Jun 5, 2024 at 21:20

1 Answer 1

0

You can reduce the parallelism of the sink to 1, while leaving the rest of the pipeline at 5. That way you'll have just one output stream. If you really need to scale the sink up to 5 instances, then they will operate independently, and create 5 separate output streams.

answered Jun 5, 2024 at 21:52
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer David but How I can reduce the parallelism in only the sink I use this code I using FileSink
You can use source.sinkTo(sinkfile).setParallelism(1) to reduce parallelism

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.