pnowojski commented on a change in pull request #6367: [FLINK-9850] Add a
string to the print method to identify output for DataStream
URL: https://github.com/apache/flink/pull/6367#discussion_r209911856
##########
File path:
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/PrintSinkFunction.java
##########
@@ -70,27 +84,30 @@ public void open(Configuration parameters) throws
Exception {
// get the target stream
stream = target == STD_OUT ? System.out : System.err;
- // set the prefix if we have a >1 parallelism
- prefix = (context.getNumberOfParallelSubtasks() > 1) ?
- ((context.getIndexOfThisSubtask() + 1) + "> ")
: null;
+ completedPrefix = sinkIdentifier;
+
+ if (context.getNumberOfParallelSubtasks() > 1) {
+ if (!completedPrefix.isEmpty()) {
+ completedPrefix += ":";
+ }
+ completedPrefix += (context.getIndexOfThisSubtask() +
1);
+ }
+
+ if (!completedPrefix.isEmpty()) {
+ completedPrefix += "> ";
+ }
}
@Override
public void invoke(IN record) {
- if (prefix != null) {
- stream.println(prefix + record.toString());
+ if (completedPrefix != null) {
Review comment:
This check is not valid anymore, this field is never null. It can either be
dropped altogether or replaced by empty string check. Probably it's better to
drop it. Functionally both will be the same and empty string check's
performance benefit (if any) doesn't matter while printing to STDOUT/STDERR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services