jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject [17/26] jena git commit: Some clean up of assignment inlining/elimination (JENA-780)
Date Tue, 07 Jul 2015 09:24:22 GMT
Some clean up of assignment inlining/elimination (JENA-780)

- Add context keys to control it as part of standard optimizer (disabled
  by default)
- When applying it don't apply inside of SERVICE


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/39e4fd59
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/39e4fd59
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/39e4fd59

Branch: refs/heads/jena2
Commit: 39e4fd590d4b859d8cf416bb928b54b749471483
Parents: d6f516d
Author: Rob Vesse <rvesse@apache.org>
Authored: Mon Jul 6 16:01:55 2015 +0100
Committer: Rob Vesse <rvesse@apache.org>
Committed: Mon Jul 6 16:01:55 2015 +0100

----------------------------------------------------------------------
 jena-arq/src/main/java/com/hp/hpl/jena/query/ARQ.java   | 12 ++++++++++++
 .../hp/hpl/jena/sparql/algebra/optimize/Optimize.java   |  4 ++++
 .../algebra/optimize/TransformEliminateAssignments.java |  5 +++--
 3 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/39e4fd59/jena-arq/src/main/java/com/hp/hpl/jena/query/ARQ.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/query/ARQ.java b/jena-arq/src/main/java/com/hp/hpl/jena/query/ARQ.java
index 5262c7e..3ebe3bc 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/query/ARQ.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/query/ARQ.java
@@ -403,6 +403,18 @@ public class ARQ
     public static final Symbol optIndexJoinStrategy = ARQConstants.allocSymbol("optIndexJoinStrategy");
     
     /**
+     * Context key controlling whether the standard optimizer applies optimizations where
by some
+     * assignments may be eliminated/inlined into the operators where their values are used
only once
+     */
+    public static final Symbol optInlineAssignments = ARQConstants.allocSymbol("optInlineAssignments");
+    
+    /**
+     * Context key controlling whether the standard optimizer aggressively inlines assignments
whose
+     * values are used only once into operators where those expressions may be evaluated
multiple times e.g. order
+     */
+    public static final Symbol optInlineAssignmentsAggressive = ARQConstants.allocSymbol("optInlineAssignmentsAggressive");
+    
+    /**
      * Context key controlling whether the standard optimizater applies optimizations to
joined BGPs to
      * merge them into single BGPs.
      * By default, this transformation is applied.

http://git-wip-us.apache.org/repos/asf/jena/blob/39e4fd59/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/Optimize.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/Optimize.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/Optimize.java
index 150e122..180bfd4 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/Optimize.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/Optimize.java
@@ -236,6 +236,10 @@ public class Optimize implements Rewrite
         if ( context.isTrue(ARQ.optFilterInequality) )
             op = apply("Filter Inequality", new TransformFilterInequality(), op);
         
+        // Eliminate/Inline assignments where possible
+        if ( context.isTrue(ARQ.optInlineAssignments) )
+            op = TransformEliminateAssignments.eliminate(op, context.isTrue(ARQ.optInlineAssignmentsAggressive));
+        
         // Promote table empty as late as possible since this will only be produced by other

         // optimizations and never directly from algebra generation
         if ( context.isTrueOrUndef(ARQ.optPromoteTableEmpty) )

http://git-wip-us.apache.org/repos/asf/jena/blob/39e4fd59/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformEliminateAssignments.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformEliminateAssignments.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformEliminateAssignments.java
index 59e77c2..c468272 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformEliminateAssignments.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformEliminateAssignments.java
@@ -78,7 +78,8 @@ import com.hp.hpl.jena.sparql.expr.NodeValue;
  * <ul>
  * <li>Filter Expressions</li>
  * <li>Bind and Select Expressions</li>
- * <li>Order By Expressions if aggressive in-lining is enabled</li>
+ * <li>Order By Expressions if aggressive in-lining is enabled or the assigned
+ * expression is a constant</li>
  * </ul>
  * <p>
  * In the case of order by we only in-line assignments when aggressive mode is
@@ -99,7 +100,7 @@ public class TransformEliminateAssignments extends TransformCopy {
         AssignmentPopper popper = new AssignmentPopper(tracker);
         Transform transform = new TransformEliminateAssignments(tracker, pusher, popper,
aggressive);
 
-        return Transformer.transform(transform, op, pusher, popper);
+        return Transformer.transformSkipService(transform, op, pusher, popper);
     }
 
     private final OpVisitor before, after;


Mime
View raw message