You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/08/22 18:55:38 UTC

svn commit: r1516517 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformExtendCombine.java

Author: rvesse
Date: Thu Aug 22 16:55:37 2013
New Revision: 1516517

URL: http://svn.apache.org/r1516517
Log:
Add TransformExtendCombine which is used to flatten extend and assign operations together where possible.

Note that normal algebra construction does this automatically but in some cases it is useful to have this as a separate transform that may be applied

Added:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformExtendCombine.java

Added: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformExtendCombine.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformExtendCombine.java?rev=1516517&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformExtendCombine.java (added)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformExtendCombine.java Thu Aug 22 16:55:37 2013
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.sparql.algebra.optimize;
+
+import com.hp.hpl.jena.sparql.algebra.Op;
+import com.hp.hpl.jena.sparql.algebra.TransformCopy;
+import com.hp.hpl.jena.sparql.algebra.Transformer;
+import com.hp.hpl.jena.sparql.algebra.op.OpAssign;
+import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
+
+/**
+ * An optimizer that aims to combine multiple extend clauses together.
+ * <p>
+ * Since the semantics of extend are such that the expressions are expected to
+ * be evaluated in order we can combine extends together. This can make
+ * evaluation more efficient because all the assignments are done in a single
+ * step though depending on the underlying store this may make little or no
+ * difference.
+ * </p>
+ * <p>
+ * Note that standard algebra construction will cause much of this to happen
+ * naturally but sometimes it is useful to apply this as an additional
+ * independent transform.
+ * </p>
+ * 
+ */
+public class TransformExtendCombine extends TransformCopy {
+
+    @Override
+    public Op transform(OpAssign opAssign, Op subOp) {
+        if (subOp instanceof OpAssign) {
+            return OpAssign.assign(Transformer.transform(this, subOp), opAssign.getVarExprList());
+        }
+        return super.transform(opAssign, subOp);
+    }
+
+    @Override
+    public Op transform(OpExtend opExtend, Op subOp) {
+        if (subOp instanceof OpExtend) {
+            return OpExtend.extend(Transformer.transform(this, subOp), opExtend.getVarExprList());
+        }
+        return super.transform(opExtend, subOp);
+    }
+}