Strabon
changeset 1448:3776ff96efea
bug #78: fixed also the case where spatial functions in SELECT did
not recognize the variables that result from a BIND.
For this, I changed the tuple expression, so that it evaluates in
Java the spatial functions that contain such kind of variables.
not recognize the variables that result from a BIND.
For this, I changed the tuple expression, so that it evaluates in
Java the spatial functions that contain such kind of variables.
author | Stella Giannakopoulou <sgian@di.uoa.gr> |
---|---|
date | Thu Dec 18 18:03:57 2014 +0200 (2014-12-18) |
parents | 47a6ec31f27c |
children | 373b66ce4884 |
files | generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java |
line diff
1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Thu Dec 18 17:56:55 2014 +0200 1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Thu Dec 18 18:03:57 2014 +0200 1.3 @@ -140,6 +140,9 @@ 1.4 1.5 private Group referenceGroupBy = null; 1.6 1.7 + //used to keep the names used in a BIND clause 1.8 + private Set<String> namesInBind = new HashSet<String>(); 1.9 + 1.10 //Counter used to enumerate expressions in having 1.11 private int havingID = 1; 1.12 1.13 @@ -993,8 +996,10 @@ 1.14 1.15 if (expr instanceof FunctionCall) 1.16 //if (expr instanceof FunctionCall && !isFuncExprGrounded(expr)) 1.17 - { // if the expr is grounded we are going to evaluate it in Java 1.18 - if(!evaluateInJava(expr)) 1.19 + { // if the expr is grounded we are going to evaluate it in Java 1.20 + //also if the function involves variables from a BIND clause 1.21 + //we evaluate it in java 1.22 + if(!evaluateInJava(expr) && !varInBind(expr)) 1.23 { 1.24 Function function = FunctionRegistry.getInstance().get(((FunctionCall) expr).getURI()); 1.25 if(function instanceof SpatialPropertyFunc || function instanceof SpatialRelationshipFunc || 1.26 @@ -1009,7 +1014,7 @@ 1.27 iter.remove(); 1.28 } 1.29 } 1.30 - else //Union (or Extent) is used as an aggregate function on Select Clause! 1.31 + else if(!varInBind(expr)) //Union (or Extent) is used as an aggregate function on Select Clause! 1.32 { 1.33 //must add as aggregate 1.34 if(this.referenceGroupBy != null) 1.35 @@ -1019,7 +1024,10 @@ 1.36 } 1.37 iter.remove(); 1.38 } 1.39 - 1.40 + //if the name of the new variable is not present in the projection 1.41 + //then it results from a BIND 1.42 + if(!(node.getParentNode() instanceof Projection)) 1.43 + namesInBind.add(name+"?spatial"); 1.44 } 1.45 //Issue: MathExpr is not exclusively met in spatial cases! 1.46 //Need to distinguish thematic and spatial!! 1.47 @@ -1254,6 +1262,32 @@ 1.48 1.49 } 1.50 1.51 + /** 1.52 + * 1.53 + * @param expr 1.54 + * @return true if the variable occurs inside a BIND clause 1.55 + * false otherwise 1.56 + */ 1.57 + private boolean varInBind(ValueExpr expr) 1.58 + { 1.59 + if(expr instanceof FunctionCall) 1.60 + { 1.61 + for(int i = 0 ; i< ((FunctionCall) expr).getArgs().size(); i++) 1.62 + { 1.63 + return varInBind(((FunctionCall) expr).getArgs().get(i)); 1.64 + } 1.65 + return false; 1.66 + } 1.67 + else if(expr instanceof Var) //Var 1.68 + { 1.69 + if(namesInBind.contains(((Var)expr).getName())) 1.70 + return true; 1.71 + return false; 1.72 + } 1.73 + else 1.74 + return false; 1.75 + } 1.76 + 1.77 @Override 1.78 public void meet(Slice node) 1.79 throws RuntimeException