[
https://issues.apache.org/jira/browse/FLINK-9850?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16579662#comment-16579662
]
ASF GitHub Bot commented on FLINK-9850:
---------------------------------------
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]
> Add a string to the print method to identify output for DataStream
> ------------------------------------------------------------------
>
> Key: FLINK-9850
> URL: https://issues.apache.org/jira/browse/FLINK-9850
> Project: Flink
> Issue Type: New Feature
> Components: DataStream API
> Reporter: Hequn Cheng
> Assignee: vinoyang
> Priority: Major
> Labels: pull-request-available
>
> The output of the print method of {[DataSet}} allows the user to supply a
> String to identify the output(see
> [FLINK-1486|https://issues.apache.org/jira/browse/FLINK-1486]). But
> {[DataStream}} doesn't support now. It is valuable to add this feature for
> {{DataStream}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)