Class FunctionSplitter

java.lang.Object
org.apache.flink.table.codesplit.FunctionSplitter
All Implemented Interfaces:
CodeRewriter

@Internal public class FunctionSplitter extends Object implements CodeRewriter
Split long functions into several smaller functions.

This rewriter only deals with functions without return values. Functions with return values should have been converted by ReturnValueRewriter. For functions with return statements, this rewriter will add a check for early returns with the help of AddBoolBeforeReturnRewriter.

Before


 public class Example {
     public void myFun(int a, int b) {
         a += b;
         b += a;
         if (a > 0) {
             return;
         }
         a *= 2;
         b *= 2;
         System.out.println(a);
         System.out.println(b);
     }
 }
 

After


 public class Example {
     boolean myFunHasReturned$0;

     public void myFun(int a, int b) {
         myFunHasReturned$0 = false;
         myFun_split1(a, b);

         myFun_split2(a, b);
         if (myFunHasReturned$0) {
             return;
         }

         myFun_split3(a, b);
     }

     void myFun_split1(int a, int b) {
         a += b;
         b += a;
     }

     void myFun_split2(int a, int b) {
         if (a > 0) {
             {
                 myFunHasReturned$0 = true;
                 return;
             }
         }
     }

     void myFun_split3(int a, int b) {
         a *= 2;
         b *= 2;
         System.out.println(a);
         System.out.println(b);
     }
 }
 
  • Constructor Details

    • FunctionSplitter

      public FunctionSplitter(String code, int maxMethodLength)
  • Method Details