forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-1380] [streaming] Updated SplitDataStream to extend DataStream…
… to get rid of selectAll method for splits
- Loading branch information
Showing
6 changed files
with
77 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 50 additions & 71 deletions
121
...reaming-core/src/main/java/org/apache/flink/streaming/api/datastream/SplitDataStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.streaming.api.datastream; | ||
|
||
import java.util.Arrays; | ||
*/ | ||
|
||
import org.apache.flink.api.common.typeinfo.TypeInformation; | ||
import org.apache.flink.streaming.api.collector.OutputSelector; | ||
|
||
/** | ||
* The SplitDataStream represents an operator that has been split using an | ||
* {@link OutputSelector}. Named outputs can be selected using the | ||
* {@link #select} function. | ||
* | ||
* @param <OUT> | ||
* The type of the output. | ||
*/ | ||
public class SplitDataStream<OUT> { | ||
|
||
DataStream<OUT> dataStream; | ||
|
||
protected SplitDataStream(DataStream<OUT> dataStream) { | ||
this.dataStream = dataStream.copy(); | ||
} | ||
package org.apache.flink.streaming.api.datastream; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.apache.flink.streaming.api.collector.OutputSelector; | ||
|
||
/** | ||
* The SplitDataStream represents an operator that has been split using an | ||
* {@link OutputSelector}. Named outputs can be selected using the | ||
* {@link #select} function. To apply transformation on the whole output simply | ||
* call the transformation on the SplitDataStream | ||
* | ||
* @param <OUT> | ||
* The type of the output. | ||
*/ | ||
public class SplitDataStream<OUT> extends DataStream<OUT> { | ||
|
||
protected SplitDataStream(DataStream<OUT> dataStream) { | ||
super(dataStream); | ||
} | ||
|
||
/** | ||
* Gets the output type. | ||
* Sets the output names for which the next operator will receive values. | ||
* | ||
* @return The output type. | ||
* @param outputNames | ||
* The output names for which the operator will receive the | ||
* input. | ||
* @return Returns the selected DataStream | ||
*/ | ||
public TypeInformation<OUT> getOutputType() { | ||
return dataStream.getType(); | ||
public DataStream<OUT> select(String... outputNames) { | ||
return selectOutput(outputNames); | ||
} | ||
|
||
private DataStream<OUT> selectOutput(String[] outputNames) { | ||
DataStream<OUT> returnStream = copy(); | ||
returnStream.selectAll = false; | ||
returnStream.userDefinedNames = Arrays.asList(outputNames); | ||
return returnStream; | ||
} | ||
|
||
/** | ||
* Sets the output names for which the next operator will receive values. | ||
* | ||
* @param outputNames | ||
* The output names for which the operator will receive the | ||
* input. | ||
* @return Returns the selected DataStream | ||
*/ | ||
public DataStream<OUT> select(String... outputNames) { | ||
return selectOutput(outputNames); | ||
} | ||
|
||
/** | ||
* Selects all output names from a split data stream. | ||
* | ||
* @return Returns the selected DataStream | ||
*/ | ||
public DataStream<OUT> selectAll() { | ||
DataStream<OUT> returnStream = dataStream.copy(); | ||
returnStream.selectAll = true; | ||
return returnStream; | ||
} | ||
|
||
private DataStream<OUT> selectOutput(String[] outputNames) { | ||
DataStream<OUT> returnStream = dataStream.copy(); | ||
returnStream.userDefinedNames = Arrays.asList(outputNames); | ||
return returnStream; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters