Strabon

changeset 781:69837cd17fb5 DiffDateTime

NOT WORKING: Down down down to postgres...
author George Garbis <ggarbis@di.uoa.gr>
date Tue Dec 04 21:05:12 2012 +0200 (2012-12-04)
parents 530257d4896e
children b9cde09d417d
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffDateTime.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/impl/stSPARQLConstantOptimizer.java evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffDateTime.java	Tue Dec 04 16:31:03 2012 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffDateTime.java	Tue Dec 04 21:05:12 2012 +0200
     1.3 @@ -13,8 +13,10 @@
     1.4  import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants;
     1.5  
     1.6  /**
     1.7 - * @author Garmpis Georgios <ggarbis@di.uoa.gr>
     1.8 - *
     1.9 + * Addition for datetime metric functions
    1.10 + * 
    1.11 + * @author George Garbis <ggarbis@di.uoa.gr>
    1.12 + * 
    1.13   */
    1.14  public class DiffDateTime extends DateTimeMetricFunc {
    1.15  
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/impl/stSPARQLConstantOptimizer.java	Tue Dec 04 16:31:03 2012 +0200
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/impl/stSPARQLConstantOptimizer.java	Tue Dec 04 21:05:12 2012 +0200
     2.3 @@ -34,6 +34,7 @@
     2.4  import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
     2.5  import org.openrdf.query.algebra.evaluation.function.Function;
     2.6  import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
     2.7 +import org.openrdf.query.algebra.evaluation.function.spatial.DateTimeMetricFunc;
     2.8  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialConstructFunc;
     2.9  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialMetricFunc;
    2.10  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialPropertyFunc;
    2.11 @@ -189,7 +190,15 @@
    2.12  			if(!(function instanceof SpatialConstructFunc) && 
    2.13  					!(function instanceof SpatialMetricFunc) &&
    2.14  					!(function instanceof SpatialPropertyFunc) &&
    2.15 -					!(function instanceof SpatialRelationshipFunc) )
    2.16 +					!(function instanceof SpatialRelationshipFunc) 
    2.17 +					/**
    2.18 +					 * Addition for datetime metric functions
    2.19 +					 * 
    2.20 +					 * @author George Garbis <ggarbis@di.uoa.gr>
    2.21 +					 * 
    2.22 +					 */
    2.23 +					&& !(function instanceof DateTimeMetricFunc)
    2.24 +				)
    2.25  			{
    2.26  				super.meet(functionCall);
    2.27  
     3.1 --- a/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Tue Dec 04 16:31:03 2012 +0200
     3.2 +++ b/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Tue Dec 04 21:05:12 2012 +0200
     3.3 @@ -81,4 +81,4 @@
     3.4  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeaturesWithinFunc
     3.5  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeatureTouchesFunc
     3.6  
     3.7 -org.openrdf.query.algebra.evaluation.util.DiffDateTime
     3.8 \ No newline at end of file
     3.9 +org.openrdf.query.algebra.evaluation.function.datetime.stsparql.metric.DiffDateTime
    3.10 \ No newline at end of file
     4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Tue Dec 04 16:31:03 2012 +0200
     4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Tue Dec 04 21:05:12 2012 +0200
     4.3 @@ -32,6 +32,7 @@
     4.4  import org.openrdf.query.algebra.evaluation.function.Function;
     4.5  import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
     4.6  import org.openrdf.query.algebra.evaluation.function.link.AddDateTimeFunc;
     4.7 +import org.openrdf.query.algebra.evaluation.function.spatial.DateTimeMetricFunc;
     4.8  import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants;
     4.9  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialConstructFunc;
    4.10  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialMetricFunc;
    4.11 @@ -121,15 +122,26 @@
    4.12  		if(left instanceof FunctionCall)
    4.13  		{
    4.14  			Function function = FunctionRegistry.getInstance().get(((FunctionCall)left).getURI());
    4.15 +			leftIsSpatial = true;
    4.16  			if(function instanceof SpatialMetricFunc)
    4.17  			{
    4.18  				leftSql = spatialMetricFunction((FunctionCall) left, function);
    4.19  			}
    4.20 +			/**
    4.21 +			 * Addition for datetime metric functions
    4.22 +			 * 
    4.23 +			 * @author George Garbis <ggarbis@di.uoa.gr>
    4.24 +			 * 
    4.25 +			 */
    4.26 +			else if (function instanceof DateTimeMetricFunc){
    4.27 +				leftSql = dateTimeMetricFunction((FunctionCall)left, function);
    4.28 +				leftIsSpatial = false;
    4.29 +			}
    4.30 +			/***/
    4.31  			else //spatial property
    4.32  			{
    4.33  				leftSql = spatialPropertyFunction((FunctionCall) left, function);
    4.34  			}
    4.35 -			leftIsSpatial = true;
    4.36  		}
    4.37  		else if(left instanceof MathExpr)
    4.38  		{
    4.39 @@ -687,6 +699,24 @@
    4.40  
    4.41  			}
    4.42  
    4.43 +	/**
    4.44 +	 * Addition for datetime metric functions
    4.45 +	 * 
    4.46 +	 * @author George Garbis <ggarbis@di.uoa.gr>
    4.47 +	 * 
    4.48 +	 */
    4.49 +	public GeneralDBSqlExpr dateTimeFunction(FunctionCall functionCall) throws UnsupportedRdbmsOperatorException
    4.50 +	{
    4.51 +		Function function = FunctionRegistry.getInstance().get(functionCall.getURI());
    4.52 +		if(function instanceof DateTimeMetricFunc) //1 argument
    4.53 +		{
    4.54 +			return dateTimeMetricFunction(functionCall,function);	
    4.55 +		}
    4.56 +		return null;
    4.57 +	}
    4.58 +
    4.59 +	/***/
    4.60 +	
    4.61  	public GeneralDBSqlExpr spatialFunction(FunctionCall functionCall) throws UnsupportedRdbmsOperatorException
    4.62  	{
    4.63  		Function function = FunctionRegistry.getInstance().get(functionCall.getURI());
    4.64 @@ -808,6 +838,45 @@
    4.65  
    4.66  	}
    4.67  
    4.68 +	/**
    4.69 +	 * Addition for datetime metric functions
    4.70 +	 * 
    4.71 +	 * @author George Garbis <ggarbis@di.uoa.gr>
    4.72 +	 * 
    4.73 +	 */
    4.74 +	GeneralDBSqlExpr dateTimeMetricFunction(FunctionCall functionCall, Function function) throws UnsupportedRdbmsOperatorException
    4.75 +	{
    4.76 +		GeneralDBSqlExpr leftArg = null;
    4.77 +		GeneralDBSqlExpr rightArg = null;
    4.78 +
    4.79 +		ValueExpr left = functionCall.getArgs().get(0);
    4.80 +		ValueExpr right = functionCall.getArgs().get(1);
    4.81 +
    4.82 +		if(left instanceof FunctionCall)
    4.83 +		{
    4.84 +			leftArg = dateTimeFunction((FunctionCall) left);
    4.85 +		}
    4.86 +		else
    4.87 +		{
    4.88 +			leftArg = label(left);
    4.89 +		}
    4.90 +
    4.91 +		if(right instanceof FunctionCall)
    4.92 +		{
    4.93 +			rightArg = spatialFunction((FunctionCall) right);
    4.94 +			rightArg = dateTimeFunction((FunctionCall) right);
    4.95 +		}
    4.96 +		else
    4.97 +		{
    4.98 +			rightArg = label(right);
    4.99 +		}
   4.100 +		
   4.101 +		return dateTimeMetricPicker(function, leftArg, rightArg);
   4.102 +
   4.103 +	}
   4.104 +
   4.105 +	/***/
   4.106 +	
   4.107  	GeneralDBSqlExpr spatialMetricFunction(FunctionCall functionCall, Function function) throws UnsupportedRdbmsOperatorException
   4.108  	{
   4.109  		GeneralDBSqlExpr leftArg = null;
     5.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Tue Dec 04 16:31:03 2012 +0200
     5.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Tue Dec 04 21:05:12 2012 +0200
     5.3 @@ -804,6 +804,7 @@
     5.4  		}
     5.5  		parameters.addAll(query.getParameters());
     5.6  
     5.7 +		System.out.println("Query: \n"+query.toString()+"\n");
     5.8  		return query.toString();
     5.9  	}
    5.10  
     6.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Tue Dec 04 16:31:03 2012 +0200
     6.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Tue Dec 04 21:05:12 2012 +0200
     6.3 @@ -64,6 +64,7 @@
     6.4  import org.openrdf.query.algebra.evaluation.QueryOptimizer;
     6.5  import org.openrdf.query.algebra.evaluation.function.Function;
     6.6  import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 
     6.7 +import org.openrdf.query.algebra.evaluation.function.spatial.DateTimeMetricFunc;
     6.8  import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants;
     6.9  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialConstructFunc;
    6.10  import org.openrdf.query.algebra.evaluation.function.spatial.SpatialMetricFunc;
    6.11 @@ -905,13 +906,13 @@
    6.12  	@Override
    6.13  	public void meet(FunctionCall node)
    6.14  			throws RuntimeException
    6.15 -			{
    6.16 +	{
    6.17  		Function function = FunctionRegistry.getInstance().get(node.getURI());
    6.18  
    6.19  		super.meet(node);
    6.20  
    6.21  		if(function instanceof SpatialRelationshipFunc || function instanceof SpatialConstructFunc 
    6.22 -				|| function instanceof SpatialMetricFunc || function instanceof SpatialPropertyFunc)
    6.23 +				|| function instanceof SpatialMetricFunc || function instanceof SpatialPropertyFunc )
    6.24  		{
    6.25  			List<ValueExpr> allArgs = node.getArgs();
    6.26  
    6.27 @@ -966,8 +967,31 @@
    6.28  			//				
    6.29  			//			}
    6.30  		}
    6.31 +		/**
    6.32 +		 * Addition for datetime metric functions
    6.33 +		 * 
    6.34 +		 * @author George Garbis <ggarbis@di.uoa.gr>
    6.35 +		 * 
    6.36 +		 */
    6.37 +		else if (function instanceof DateTimeMetricFunc)
    6.38 +		{
    6.39 +			List<ValueExpr> allArgs = node.getArgs();
    6.40  
    6.41 +			int argNo = 0; 
    6.42 +			//Used so that the second argument of buffer func is not 
    6.43 +			//mistakenly confused with a spatial variable
    6.44 +			for(ValueExpr arg : allArgs)
    6.45 +			{	
    6.46 +				argNo++;
    6.47 +				if(arg instanceof Var && argNo!=2)
    6.48 +				{
    6.49 +					String originalName = ((Var)arg).getName();
    6.50 +					((Var)arg).setName(originalName);
    6.51 +				}
    6.52  			}
    6.53 +		}
    6.54 +		/***/
    6.55 +	}
    6.56  
    6.57  	//
    6.58  	@Override
     7.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java	Tue Dec 04 16:31:03 2012 +0200
     7.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java	Tue Dec 04 21:05:12 2012 +0200
     7.3 @@ -49,7 +49,7 @@
     7.4  
     7.5  		Strabon strabon = null;
     7.6  		try {
     7.7 -			strabon = new Strabon(db, user, passwd, port, host, false);
     7.8 +			strabon = new Strabon(db, user, passwd, port, host, true);
     7.9  			strabon.query(queryString, Format.fromString(resultsFormat), strabon.getSailRepoConnection(), System.out);
    7.10  			
    7.11  		} catch (Exception e) {