Package org.apache.calcite.linq4j.tree
Class ClassDeclarationFinder
java.lang.Object
org.apache.calcite.linq4j.tree.Shuttle
org.apache.calcite.linq4j.tree.ClassDeclarationFinder
- Direct Known Subclasses:
- DeterministicCodeOptimizer
Entry point for optimizers that factor out deterministic expressions to
 final static fields.
 Instances of this class should not be reused, so new visitor should be
 created for optimizing a new expression tree.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final List<MemberDeclaration>The list of new final static fields to be added to the current class.protected final @Nullable ClassDeclarationFinder
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreates a child optimizer.
- 
Method SummaryModifier and TypeMethodDescriptionstatic ClassDeclarationFindercreate()Creates visitor that uses default optimizer.static ClassDeclarationFindercreate(Class<? extends ClassDeclarationFinder> optimizingClass) Creates visitor that uses given class as optimizer.static ClassDeclarationFindercreate(Function1<ClassDeclarationFinder, ClassDeclarationFinder> childFactory) Creates visitor that uses given factory to create optimizers.protected @Nullable ParameterExpressionfindDeclaredExpression(Expression expression) Finds if there exists ready for reuse declaration for given expression.protected ClassDeclarationFindergoDeeper()Creates child visitor.protected booleanVerifies if the variable name is already in use.protected booleanisConstant(Iterable<? extends Expression> list) Verifies if all the expressions in given list are effectively constant.protected booleanisConstant(Expression expression) Verifies if the expression is effectively constant.protected voidlearnFinalStaticDeclarations(List<MemberDeclaration> memberDeclarations) Processes the list of declarations when class expression detected.protected List<MemberDeclaration>optimizeDeclarations(List<MemberDeclaration> memberDeclarations) Adds new declarations (e.g.preVisit(ClassDeclaration classDeclaration) Creates optimizer local to the newly generated class.preVisit(NewExpression newExpression) Creates optimizer local to the newly generated anonymous class.protected ExpressiontryOptimizeNewInstance(NewExpression newExpression) Optimizesnew Type()constructs.visit(ClassDeclaration classDeclaration, List<MemberDeclaration> memberDeclarations) visit(NewExpression newExpression, List<Expression> arguments, @Nullable List<MemberDeclaration> memberDeclarations) Methods inherited from class org.apache.calcite.linq4j.tree.ShuttlepreVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, preVisit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
- 
Field Details- 
parent
- 
addedDeclarationsThe list of new final static fields to be added to the current class.
 
- 
- 
Constructor Details- 
ClassDeclarationFinderCreates a child optimizer. Typically a child is created for each class declaration, so each optimizer collects fields for exactly one class.- Parameters:
- parent- parent optimizer
 
 
- 
- 
Method Details- 
createCreates visitor that uses default optimizer.- Returns:
- optimizing visitor
 
- 
createpublic static ClassDeclarationFinder create(Class<? extends ClassDeclarationFinder> optimizingClass) Creates visitor that uses given class as optimizer. The implementation should support (ClassDeclarationFinder) constructor.- Parameters:
- optimizingClass- class that implements optimizations
- Returns:
- optimizing visitor
 
- 
createpublic static ClassDeclarationFinder create(Function1<ClassDeclarationFinder, ClassDeclarationFinder> childFactory) Creates visitor that uses given factory to create optimizers.- Parameters:
- childFactory- factory that creates optimizers
- Returns:
- optimizing visitor
 
- 
preVisitCreates optimizer local to the newly generated anonymous class.
- 
preVisitCreates optimizer local to the newly generated class.
- 
visitpublic Expression visit(NewExpression newExpression, List<Expression> arguments, @Nullable List<MemberDeclaration> memberDeclarations) 
- 
learnFinalStaticDeclarationsProcesses the list of declarations when class expression detected. Sub-classes might figure out the existing fields for reuse.- Parameters:
- memberDeclarations- list of declarations to process.
 
- 
tryOptimizeNewInstanceOptimizesnew Type()constructs.- Parameters:
- newExpression- expression to optimize
- Returns:
- always returns un-optimized expression
 
- 
visitpublic ClassDeclaration visit(ClassDeclaration classDeclaration, List<MemberDeclaration> memberDeclarations) 
- 
optimizeDeclarationsAdds new declarations (e.g. final static fields) to the list of existing ones.- Parameters:
- memberDeclarations- existing list of declarations
- Returns:
- new list of declarations or the same if no modifications required
 
- 
isConstantVerifies if the expression is effectively constant. This method should be overridden in sub-classes.- Parameters:
- expression- expression to test
- Returns:
- always returns false
 
- 
isConstantVerifies if all the expressions in given list are effectively constant.- Parameters:
- list- list of expressions to test
- Returns:
- true when all the expressions are known to be constant
 
- 
findDeclaredExpressionFinds if there exists ready for reuse declaration for given expression. This method should be overridden in sub-classes.- Parameters:
- expression- input expression
- Returns:
- always returns null
 
- 
hasFieldVerifies if the variable name is already in use. This method should be overridden in sub-classes.- Parameters:
- name- name of the variable to test
- Returns:
- always returns false
 
- 
goDeeperCreates child visitor. It is used to traverse nested class declarations.- Returns:
- new Visitorthat is used to optimize class declarations
 
 
-