forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-35795][API] Introduce the framework of ProcessFunction Attribute
- Loading branch information
Showing
18 changed files
with
581 additions
and
35 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
flink-core/src/main/java/org/apache/flink/api/common/attribute/Attribute.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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://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.api.common.attribute; | ||
|
||
import org.apache.flink.annotation.Internal; | ||
|
||
import java.io.Serializable; | ||
|
||
/** {@link Attribute} contains the information about the process logic of a process function. */ | ||
@Internal | ||
public class Attribute implements Serializable { | ||
|
||
private boolean isNoOutputUntilEndOfInput; | ||
|
||
private Attribute(boolean isNoOutputUntilEndOfInput) { | ||
this.isNoOutputUntilEndOfInput = isNoOutputUntilEndOfInput; | ||
} | ||
|
||
public boolean isNoOutputUntilEndOfInput() { | ||
return isNoOutputUntilEndOfInput; | ||
} | ||
|
||
public void setNoOutputUntilEndOfInput(boolean noOutputUntilEndOfInput) { | ||
isNoOutputUntilEndOfInput = noOutputUntilEndOfInput; | ||
} | ||
|
||
@Internal | ||
public static class Builder { | ||
|
||
private boolean isNoOutputUntilEndOfInput = false; | ||
|
||
public Builder setNoOutputUntilEndOfInput(boolean isNoOutputUntilEndOfInput) { | ||
this.isNoOutputUntilEndOfInput = isNoOutputUntilEndOfInput; | ||
return this; | ||
} | ||
|
||
public Attribute build() { | ||
return new Attribute(isNoOutputUntilEndOfInput); | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...-api/src/main/java/org/apache/flink/datastream/api/attribute/NoOutputUntilEndOfInput.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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://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.datastream.api.attribute; | ||
|
||
import org.apache.flink.annotation.Experimental; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* {@link NoOutputUntilEndOfInput} indicates that the process function will only output records | ||
* after all inputs are ended. If this annotation is applied to a process function with an unbounded | ||
* source, a compilation error will occur. | ||
*/ | ||
@Experimental | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface NoOutputUntilEndOfInput {} |
36 changes: 36 additions & 0 deletions
36
...-datastream/src/main/java/org/apache/flink/datastream/impl/attribute/AttributeParser.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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://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.datastream.impl.attribute; | ||
|
||
import org.apache.flink.api.common.attribute.Attribute; | ||
import org.apache.flink.datastream.api.attribute.NoOutputUntilEndOfInput; | ||
import org.apache.flink.datastream.api.function.ProcessFunction; | ||
|
||
/** {@link AttributeParser} is used to parse {@link Attribute} from {@link ProcessFunction}. */ | ||
public class AttributeParser { | ||
|
||
public static Attribute parseAttribute(ProcessFunction function) { | ||
Class<? extends ProcessFunction> functionClass = function.getClass(); | ||
Attribute.Builder attributeBuilder = new Attribute.Builder(); | ||
if (functionClass.isAnnotationPresent(NoOutputUntilEndOfInput.class)) { | ||
attributeBuilder.setNoOutputUntilEndOfInput(true); | ||
} | ||
return attributeBuilder.build(); | ||
} | ||
} |
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
Oops, something went wrong.