[ 
https://issues.apache.org/jira/browse/JENA-630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13973930#comment-13973930
 ] 

Andy Seaborne commented on JENA-630:
------------------------------------

You are right that we ought to have the constant folding logic in one place and 
having a foldability test is much cleaner .  There does not seem to be a need 
to {{.copy}} explicitly or {{.copySubstitute}} if constant folding logic is in 
{{ExprTransformConstantFold}}.

With the constant folding logic can be removed from {{copySubstitute()}} (it's 
even noted in {{Expr}}!) and put in {{ExprTransformConstantFold}}, the pattern 
in ExprTransformConstantFold is to test fpof foldability and attempt to fold if 
all the arguments are constants via {{eval(constants)}} (maybe this needs 
renaming?). This is no binding substitution so {{copySubstitute()}} now has two 
unrelated parts.

NodeValues should never need to be copied (they never depend on the binding so 
they are immutable once created, except for the delay in forming the node if 
just an intermediate value.  If they isn't true, then there is a separate bug 
somewhere. The test suite passes if NodeValue copy is "return this").

Expr can have two operations: "copy" (a deep copy) and "copySubstitute(Binding 
binding)". Folding is all in {{ExprTransformConstantFold}}.  

Add a static function to ExprLib to wrap up the functionality.

{{copySubstitute(, foldConstants)}} is deprecated and unused in the code base. 
An implementation left in place which calls {{copySubstitute(Binding)}} and 
{{ExprLib.foldConstants}}.

Cleaned up and factored code attached in the patch




> Do constant folding as part of query optimisation
> -------------------------------------------------
>
>                 Key: JENA-630
>                 URL: https://issues.apache.org/jira/browse/JENA-630
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: ARQ
>    Affects Versions: Jena 2.11.1
>            Reporter: Rob Vesse
>            Assignee: Rob Vesse
>            Priority: Minor
>             Fix For: Jena 2.11.2
>
>         Attachments: DevMain.java, ExprTransformConstantFold.java
>
>
> Currently Jena does not automatically simplify expressions by constant 
> folding even though the function API actually has support for this already 
> baked into it.
> This issue will track work to integrate a transform for this into the 
> standard optimiser.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to