jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/3] jena git commit: Reformat
Date Fri, 08 Jan 2016 22:36:46 GMT
Reformat

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

Branch: refs/heads/master
Commit: 925ef1079f60e486a71c81e4e11e5c6dcdb9cdfc
Parents: 9c33e84
Author: Andy Seaborne <andy@apache.org>
Authored: Fri Jan 8 21:36:02 2016 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Fri Jan 8 21:36:02 2016 +0000

----------------------------------------------------------------------
 .../algebra/optimize/TransformExpandOneOf.java  | 116 +++++++++----------
 1 file changed, 54 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/925ef107/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformExpandOneOf.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformExpandOneOf.java
b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformExpandOneOf.java
index 9bff870..76f8c2d 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformExpandOneOf.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/optimize/TransformExpandOneOf.java
@@ -18,15 +18,15 @@
 
 package org.apache.jena.sparql.algebra.optimize;
 
-import static org.apache.jena.sparql.expr.NodeValue.FALSE ;
-import static org.apache.jena.sparql.expr.NodeValue.TRUE ;
+import static org.apache.jena.sparql.expr.NodeValue.FALSE;
+import static org.apache.jena.sparql.expr.NodeValue.TRUE;
 
-import org.apache.jena.sparql.ARQInternalErrorException ;
-import org.apache.jena.sparql.algebra.Op ;
-import org.apache.jena.sparql.algebra.TransformCopy ;
-import org.apache.jena.sparql.algebra.op.OpFilter ;
-import org.apache.jena.sparql.algebra.op.OpLeftJoin ;
-import org.apache.jena.sparql.expr.* ;
+import org.apache.jena.sparql.ARQInternalErrorException;
+import org.apache.jena.sparql.algebra.Op;
+import org.apache.jena.sparql.algebra.TransformCopy;
+import org.apache.jena.sparql.algebra.op.OpFilter;
+import org.apache.jena.sparql.algebra.op.OpLeftJoin;
+import org.apache.jena.sparql.expr.*;
 
 public class TransformExpandOneOf extends TransformCopy
 {
@@ -35,91 +35,83 @@ public class TransformExpandOneOf extends TransformCopy
     // Expressions to expand can be in two places: OpFilter and the expr of OpLeftJoin. 
     
     @Override
-    public Op transform(OpFilter opFilter, Op subOp)
-    {
-        ExprList exprList = opFilter.getExprs() ;
-        ExprList exprList2 = process(exprList) ;
+    public Op transform(OpFilter opFilter, Op subOp) {
+        ExprList exprList = opFilter.getExprs();
+        ExprList exprList2 = process(exprList);
         if ( exprList2 == null )
-            return super.transform(opFilter, subOp) ;
-        Op opFilter2 = OpFilter.filter(exprList2, subOp) ;
-        return opFilter2 ;
+            return super.transform(opFilter, subOp);
+        Op opFilter2 = OpFilter.filter(exprList2, subOp);
+        return opFilter2;
     }
-    
+
     @Override
-    public Op transform(OpLeftJoin opLeftJoin, Op opLeft, Op opRight)
-    {
-        ExprList exprList = opLeftJoin.getExprs() ;
+    public Op transform(OpLeftJoin opLeftJoin, Op opLeft, Op opRight) {
+        ExprList exprList = opLeftJoin.getExprs();
         if ( exprList == null )
-            return opLeftJoin ;
-        ExprList exprList2 = process(exprList) ;
+            return opLeftJoin;
+        ExprList exprList2 = process(exprList);
         if ( exprList2 == null )
-            return opLeftJoin ;
-        return OpLeftJoin.create(opLeft, opRight, exprList2) ;
+            return opLeftJoin;
+        return OpLeftJoin.create(opLeft, opRight, exprList2);
     }
 
-    private static ExprList process(ExprList exprList)
-    {
+    private static ExprList process(ExprList exprList) {
         if ( !interesting(exprList) )
-            return null ;
-        return expand(exprList) ; 
+            return null;
+        return expand(exprList);
     }
     
     /** Prescan to see if anything to consider */ 
-    private static boolean interesting(ExprList exprList)
-    {
-        return exprList.getList().stream().anyMatch((e)->processable(e)) ;
+    private static boolean interesting(ExprList exprList) {
+        return exprList.getList().stream().anyMatch((e) -> processable(e));
     }
-    
+
+    /** Check whether the expression is to be processed here */ 
     private static boolean processable(Expr e) {
-        return ( e instanceof E_OneOfBase ) && ((E_OneOfBase)e).getRHS().size() <
REWRITE_LIMIT ;
+        return (e instanceof E_OneOfBase) && ((E_OneOfBase)e).getRHS().size() <
REWRITE_LIMIT;
     }
-    
-    private static int REWRITE_LIMIT = 250 ;
-    
-    private static ExprList expand(ExprList exprList)
-    {
+
+    private static int REWRITE_LIMIT = 250;
+
+    private static ExprList expand(ExprList exprList) {
         ExprList exprList2 = new ExprList() ;
         
-        for (  Expr e : exprList)
-        {
-            
-            if ( ! processable(e) ) {
-                exprList2.add(e) ;
-                continue ;
+        for ( Expr e : exprList ) {
+
+            if ( !processable(e) ) {
+                exprList2.add(e);
+                continue;
             }
-            
-            if ( e instanceof E_OneOf )
-            {
+
+            if ( e instanceof E_OneOf ) {
                 // ?x IN (a,b) ===> (?x == a) || (?x == b)
-                // ?x IN ()    ===> false
+                // ?x IN () ===> false
 
                 E_OneOf exprOneOf = (E_OneOf)e ;
                 if ( exprOneOf.getRHS().size() > REWRITE_LIMIT )
                     // Too large - leave it alone.
-                    continue ;
-                Expr x = exprOneOf.getLHS() ;
-                Expr disjunction = null ;
-                // if ?x IN () then it's false regardless.  
-                for ( Expr sub : exprOneOf.getRHS() )
-                {
-                    Expr e2 = new E_Equals(x, sub) ;
+                    continue;
+                Expr x = exprOneOf.getLHS();
+                Expr disjunction = null;
+                // if ?x IN () then it's false regardless.
+                for ( Expr sub : exprOneOf.getRHS() ) {
+                    Expr e2 = new E_Equals(x, sub);
                     if ( disjunction == null )
-                        disjunction = e2 ;
+                        disjunction = e2;
                     else
-                        disjunction = new E_LogicalOr(disjunction, e2) ;
+                        disjunction = new E_LogicalOr(disjunction, e2);
                 }
 
                 if ( disjunction == null )
-                    exprList2.add(FALSE) ;
+                    exprList2.add(FALSE);
                 else
-                    exprList2.add(disjunction) ;
-                continue ;
+                    exprList2.add(disjunction);
+                continue;
             }
-            if ( e instanceof E_NotOneOf )
-            {
+            if ( e instanceof E_NotOneOf ) {
                 // ?x NOT IN (a,b) ===> (?x != a) && (?x != b)
                 // ?x NOT IN () ===> TRUE (or nothing)
-                E_NotOneOf exprNotOneOf = (E_NotOneOf)e ;
+                E_NotOneOf exprNotOneOf = (E_NotOneOf)e;
                 if ( exprNotOneOf.getRHS().size() > REWRITE_LIMIT )
                     // Too large - leave it alone.
                     continue ;


Mime
View raw message