Package org.apache.flink.table.codesplit
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 withreturnstatements, this rewriter will add a check for early returns with the help ofAddBoolBeforeReturnRewriter.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 Summary
Constructors Constructor Description FunctionSplitter(String code, int maxMethodLength)
-
-
-
Constructor Detail
-
FunctionSplitter
public FunctionSplitter(String code, int maxMethodLength)
-
-
Method Detail
-
rewrite
public String rewrite()
- Specified by:
rewritein interfaceCodeRewriter
-
-