lindong28 commented on code in PR #22897:
URL: https://github.com/apache/flink/pull/22897#discussion_r1246386405


##########
flink-core/src/main/java/org/apache/flink/api/common/functions/Function.java:
##########
@@ -27,4 +28,17 @@
  * method) interfaces that can be implemented via Java 8 lambdas.
  */
 @Public
-public interface Function extends java.io.Serializable {}
+public interface Function extends java.io.Serializable {
+
+    /**
+     * Whether the function will modify the input records inplace. By default, 
this method return
+     * true for safety reason. If the function doesn't modify the input data, 
it should overwrite
+     * this method to return false for better performance.
+     *
+     * @return Whether the function will modify the input data inplace.
+     */
+    @Internal
+    default boolean willModifyInput() {

Review Comment:
   It is probably incorrect to say "Whether the function will modify the input 
records inplace". This is because this method is allowed to return true even if 
"the function does not modify the input records inplace".
   
   Also note that we should be able to support object-reuse even if the 
function modify input, as long as the function do not cache/modify those 
records that have already been emitted.
   
   ```
   /**
    * If this method returns true, it is guaranteed that this function will not
    * cache/modify those records that it has previously emitted.
    */
   @Internal
   default boolean isObjctResuseCompliant() {
       return false;
   }
   ```



##########
flink-core/src/main/java/org/apache/flink/api/common/functions/Function.java:
##########
@@ -27,4 +28,17 @@
  * method) interfaces that can be implemented via Java 8 lambdas.
  */
 @Public
-public interface Function extends java.io.Serializable {}
+public interface Function extends java.io.Serializable {
+
+    /**
+     * Whether the function will modify the input records inplace. By default, 
this method return
+     * true for safety reason. If the function doesn't modify the input data, 
it should overwrite
+     * this method to return false for better performance.
+     *
+     * @return Whether the function will modify the input data inplace.
+     */
+    @Internal
+    default boolean willModifyInput() {

Review Comment:
   It is probably incorrect to say "Whether the function will modify the input 
records inplace". This is because this method is allowed to return true even if 
"the function does not modify the input records inplace".
   
   Also note that we should be able to support object-reuse even if the 
function modify input, as long as the function do not cache/modify those 
records that have already been emitted.
   
   ```
   /**
    * If this method returns true, it is guaranteed that this function will not
    * cache/modify those records that it has previously emitted.
    */
   @Internal
   default boolean isObjectResuseCompliant() {
       return false;
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to