Strabon

changeset 1418:a232e3307693

more type checking in extension functions in SELECT clause; added also some FIXME and TODO notes
author Babis Nikolaou <charnik@di.uoa.gr>
date Mon Sep 22 16:35:25 2014 +0300 (2014-09-22)
parents a1cf22bfb573
children f602e11d476f
files generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Mon Sep 22 16:24:07 2014 +0300
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Mon Sep 22 16:35:25 2014 +0300
     1.3 @@ -812,7 +812,9 @@
     1.4  		return null;
     1.5  	}
     1.6  
     1.7 -
     1.8 +	/**
     1.9 +	 * TODO check required number of arguments
    1.10 +	 */
    1.11  	GeneralDBSqlExpr spatialRelationshipFunction(FunctionCall functionCall, Function function) throws UnsupportedRdbmsOperatorException
    1.12  	{
    1.13  		ValueExpr left = functionCall.getArgs().get(0);
    1.14 @@ -852,6 +854,9 @@
    1.15  		return spatialRelationshipPicker(function, leftArg, rightArg, thirdArg);
    1.16  	}
    1.17  
    1.18 +	/**
    1.19 +	 * TODO check required number of arguments
    1.20 +	 */
    1.21  	GeneralDBSqlExpr spatialConstructFunction(FunctionCall functionCall, Function function) throws UnsupportedRdbmsOperatorException
    1.22  	{
    1.23  		GeneralDBSqlExpr leftArg = null;
    1.24 @@ -948,6 +953,9 @@
    1.25  
    1.26  	}
    1.27  
    1.28 +	/**
    1.29 +	 * TODO check required number of arguments
    1.30 +	 */
    1.31  	GeneralDBSqlExpr spatialMetricFunction(FunctionCall functionCall, Function function) throws UnsupportedRdbmsOperatorException
    1.32  	{
    1.33  		GeneralDBSqlExpr leftArg = null;
    1.34 @@ -1188,6 +1196,10 @@
    1.35  	}
    1.36  
    1.37  
    1.38 +	
    1.39 +	/**
    1.40 +	 * FIXME don't check function using getURI(); use instanceof instead 
    1.41 +	 */
    1.42  	GeneralDBSqlExpr spatialConstructPicker(Function function,GeneralDBSqlExpr leftArg, GeneralDBSqlExpr rightArg, GeneralDBSqlExpr thirdArg)
    1.43  	{
    1.44  		if(function.getURI().equals(GeoConstants.stSPARQLunion))
    1.45 @@ -1278,6 +1290,7 @@
    1.46  	 * 
    1.47  	 * @author George Garbis <ggarbis@di.uoa.gr>
    1.48  	 * 
    1.49 +	 * FIXME don't check function using getURI(); use instanceof instead
    1.50  	 */
    1.51  	GeneralDBSqlExpr dateTimeMetricPicker(Function function,GeneralDBSqlExpr leftArg, GeneralDBSqlExpr rightArg)
    1.52  	{
    1.53 @@ -1290,7 +1303,10 @@
    1.54  		return null;
    1.55  	}
    1.56  	
    1.57 -	//TODO more to be added here probably
    1.58 +	/**
    1.59 +	 * TODO check required number of arguments
    1.60 +	 * FIXME don't check function using getURI(); use instanceof instead 
    1.61 +	 */
    1.62  	GeneralDBSqlExpr spatialMetricPicker(Function function,GeneralDBSqlExpr leftArg, GeneralDBSqlExpr rightArg, GeneralDBSqlExpr thirdArg)
    1.63  	{
    1.64  		if(function.getURI().equals(GeoConstants.stSPARQLdistance))
    1.65 @@ -1310,6 +1326,9 @@
    1.66  		return null;
    1.67  	}
    1.68  
    1.69 +	/**
    1.70 +	 * FIXME don't check function using getURI(); use instanceof instead
    1.71 +	 */
    1.72  	GeneralDBSqlExpr spatialPropertyPicker(Function function, GeneralDBSqlExpr arg)
    1.73  	{
    1.74  		if(function.getURI().equals(GeoConstants.stSPARQLdimension))
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Mon Sep 22 16:24:07 2014 +0300
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Mon Sep 22 16:35:25 2014 +0300
     2.3 @@ -375,6 +375,9 @@
     2.4  			else if(function instanceof SpatialRelationshipFunc)	{
     2.5  				// Any boolean function present in HAVING - Must evaluate here!
     2.6  				
     2.7 +				// check required number of arguments
     2.8 +				checkArgs(leftResult, rightResult, thirdResult, 2);
     2.9 +				
    2.10  				boolean funcResult = false;
    2.11  				
    2.12  				// get the geometries and the SRIDs of the left/right arguments
    2.13 @@ -541,6 +544,9 @@
    2.14  		}
    2.15  	}
    2.16  
    2.17 +	/**
    2.18 +	 * FIXME don't check function using getURI(); use instanceof instead 
    2.19 +	 */
    2.20  	public StrabonPolyhedron spatialConstructPicker(Function function, Value left, Value right, Value third) throws Exception
    2.21  	{
    2.22  		StrabonPolyhedron leftArg = getValueAsStrabonPolyhedron(left);
    2.23 @@ -705,7 +711,7 @@
    2.24  		return Long.MAX_VALUE;
    2.25  	}
    2.26  
    2.27 -	//XXX brought it here to override it somehow..
    2.28 +	// brought it here to override it somehow..
    2.29  	//	@Override
    2.30  	//	public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Extension extension,
    2.31  	//			BindingSet bindings)
    2.32 @@ -714,7 +720,7 @@
    2.33  	//		CloseableIteration<BindingSet, QueryEvaluationException> result;
    2.34  	//		
    2.35  	//		/**
    2.36 -	//		 * XXX additions
    2.37 +	//		 * additions
    2.38  	//		 */
    2.39  	//		Iterator<ExtensionElem> iter = extension.getElements().iterator();
    2.40  	//		//for(ExtensionElem elem : extension.getElements())
    2.41 @@ -781,7 +787,7 @@
    2.42  				for (String name : qb.getBindingNames(var)) {
    2.43  					if (!bindings.hasBinding(name)) {
    2.44  						var.setIndex(index);
    2.45 -						//XXX if the variable is actually a GeoVar
    2.46 +						// if the variable is actually a GeoVar
    2.47  						if(var.isSpatial())
    2.48  						{
    2.49  							this.geoNames.put(var.getName(), var.getIndex() + 2);
    2.50 @@ -792,7 +798,7 @@
    2.51  						query.select(proj.getStringValue());
    2.52  						index += 2;
    2.53  						if (var.getTypes().isLiterals()) {
    2.54 -							//FIXME changed  to remove extra unneeded joins + selections
    2.55 +							// NOTE: changed to remove extra unneeded joins + selections
    2.56  							//Original:
    2.57  							//query.select(proj.getLanguage());
    2.58  							//query.select(proj.getDatatype());
    2.59 @@ -816,7 +822,7 @@
    2.60  			}
    2.61  		}
    2.62  
    2.63 -		//XXX Attention: Will try to add projections in select for the constructs
    2.64 +		// Attention: Will try to add projections in select for the constructs
    2.65  		Iterator it = qb.getSpatialConstructs().entrySet().iterator();
    2.66  		while (it.hasNext()) {
    2.67  			@SuppressWarnings("rawtypes")