Strabon

changeset 785:5ec8a9894fe2 DiffDateTime

At last a working version of diffDateTime. It still doesn't work in selection but for joins it's ok :)
author George Garbis <ggarbis@di.uoa.gr>
date Fri Dec 07 22:28:26 2012 +0200 (2012-12-07)
parents ece107a3cf59
children 517cca513459
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffDateTime.java generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffDateTime.java	Thu Dec 06 13:15:24 2012 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffDateTime.java	Fri Dec 07 22:28:26 2012 +0200
     1.3 @@ -22,11 +22,14 @@
     1.4  /**
     1.5   * Addition for datetime metric functions
     1.6   * 
     1.7 + * 
     1.8   * @author George Garbis <ggarbis@di.uoa.gr>
     1.9   * 
    1.10   */
    1.11  public class DiffDateTime extends DateTimeMetricFunc {
    1.12  
    1.13 +	// This functions returns the difference in msecs of two xsd:dateTimes
    1.14 +	
    1.15  	@Override
    1.16  	public String getURI() {
    1.17  		return GeoConstants.diffDateTime;
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Thu Dec 06 13:15:24 2012 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Fri Dec 07 22:28:26 2012 +0200
     2.3 @@ -283,7 +283,7 @@
     2.4  					rightSql = numeric(right);
     2.5  				}
     2.6  
     2.7 -				if(!leftIsSpatial && !leftIsSpatial)
     2.8 +				if(!leftIsSpatial && !leftIsDateTime)
     2.9  				{
    2.10  					leftSql = numeric(right);
    2.11  				}
    2.12 @@ -867,7 +867,7 @@
    2.13  		}
    2.14  		else
    2.15  		{
    2.16 -			leftArg = label(left);
    2.17 +			leftArg = time(left);
    2.18  		}
    2.19  
    2.20  		if(right instanceof FunctionCall)
    2.21 @@ -877,7 +877,7 @@
    2.22  		}
    2.23  		else
    2.24  		{
    2.25 -			rightArg = label(right);
    2.26 +			rightArg = time(right);
    2.27  		}
    2.28  		
    2.29  		return dateTimeMetricPicker(function, leftArg, rightArg);
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Thu Dec 06 13:15:24 2012 +0200
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Fri Dec 07 22:28:26 2012 +0200
     3.3 @@ -799,7 +799,7 @@
     3.4  							//					}
     3.5  							//					else //DEFAULT CASE
     3.6  							//					{
     3.7 -							query.addFilter(sql.createBooleanExpr(expr));
     3.8 + 							query.addFilter(sql.createBooleanExpr(expr));
     3.9  							//					}
    3.10  
    3.11  						}
     4.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Dec 06 13:15:24 2012 +0200
     4.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Dec 07 22:28:26 2012 +0200
     4.3 @@ -10,6 +10,7 @@
     4.4  
     4.5  import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron;
     4.6  import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar;
     4.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBDateTimeColumn;
     4.8  import org.openrdf.sail.generaldb.algebra.GeneralDBDoubleValue;
     4.9  import org.openrdf.sail.generaldb.algebra.GeneralDBLabelColumn;
    4.10  import org.openrdf.sail.generaldb.algebra.GeneralDBNumericColumn;
    4.11 @@ -245,6 +246,12 @@
    4.12  			}
    4.13  
    4.14  	@Override
    4.15 +	protected void append(GeneralDBDateTimeColumn var, GeneralDBSqlExprBuilder filter) {
    4.16 +		String alias = getDateTimeAlias(var.getRdbmsVar());
    4.17 +		filter.column(alias, "value");
    4.18 +	}
    4.19 +	
    4.20 +	@Override
    4.21  	protected void append(GeneralDBLabelColumn var, GeneralDBSqlExprBuilder filter) {
    4.22  		if (var.getRdbmsVar().isResource()) {
    4.23  			filter.appendNull();
    4.24 @@ -1341,29 +1348,25 @@
    4.25  				String raw = arg.getValue();
    4.26  				filter.append(" "+raw+" ");
    4.27  			}
    4.28 -			else if(expr.getLeftArg() instanceof GeneralDBDoubleValue) //case met in buffer!
    4.29 +//			else if(expr.getLeftArg() instanceof GeneralDBDoubleValue) //case met in buffer!
    4.30 +//			{
    4.31 +//				append(((GeneralDBDoubleValue)expr.getLeftArg()), filter);
    4.32 +//			}
    4.33 +//			else if(expr.getLeftArg() instanceof GeneralDBNumericColumn) //case met in buffer!
    4.34 +//			{
    4.35 +//				append(((GeneralDBNumericColumn)expr.getLeftArg()), filter);
    4.36 +//			}
    4.37 +//			else if(expr.getLeftArg() instanceof GeneralDBURIColumn) //case met in transform!
    4.38 +//			{
    4.39 +//				filter.keepSRID_part1();
    4.40 +//				append(((GeneralDBURIColumn)expr.getLeftArg()), filter);
    4.41 +//				filter.keepSRID_part2();
    4.42 +//				append(((GeneralDBURIColumn)expr.getLeftArg()), filter);
    4.43 +//				filter.keepSRID_part3();
    4.44 +//			}
    4.45 +			else if(expr.getLeftArg() instanceof GeneralDBDateTimeColumn)
    4.46  			{
    4.47 -				append(((GeneralDBDoubleValue)expr.getLeftArg()), filter);
    4.48 -			}
    4.49 -			else if(expr.getLeftArg() instanceof GeneralDBNumericColumn) //case met in buffer!
    4.50 -			{
    4.51 -				append(((GeneralDBNumericColumn)expr.getLeftArg()), filter);
    4.52 -			}
    4.53 -			else if(expr.getLeftArg() instanceof GeneralDBURIColumn) //case met in transform!
    4.54 -			{
    4.55 -				filter.keepSRID_part1();
    4.56 -				append(((GeneralDBURIColumn)expr.getLeftArg()), filter);
    4.57 -				filter.keepSRID_part2();
    4.58 -				append(((GeneralDBURIColumn)expr.getLeftArg()), filter);
    4.59 -				filter.keepSRID_part3();
    4.60 -			}
    4.61 -			//case met in buffer when in select -> buffer(?spatial,?thematic)
    4.62 -			else if(expr.getLeftArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getLeftArg()).isSpatial())
    4.63 -			{	// TODO auto den einai swsto giati mporei na mhn ginei apply 
    4.64 -				// mono se dateTime values
    4.65 -				filter.append(" extract(epoch from ");
    4.66 -				append(((GeneralDBLabelColumn)expr.getLeftArg()),filter);
    4.67 -				filter.append("::timestamp) ");
    4.68 +				append(((GeneralDBDateTimeColumn)expr.getLeftArg()),filter);
    4.69  			}
    4.70  			else
    4.71  			{
    4.72 @@ -1381,30 +1384,25 @@
    4.73  				String raw = arg.getValue();
    4.74  				filter.append(" "+raw+" ");
    4.75  			}
    4.76 -			else if(expr.getRightArg() instanceof GeneralDBDoubleValue) //case met in buffer!
    4.77 +//			else if(expr.getRightArg() instanceof GeneralDBDoubleValue) //case met in buffer!
    4.78 +//			{
    4.79 +//				append(((GeneralDBDoubleValue)expr.getRightArg()), filter);
    4.80 +//			}
    4.81 +//			else if(expr.getRightArg() instanceof GeneralDBNumericColumn) //case met in buffer!
    4.82 +//			{
    4.83 +//				append(((GeneralDBNumericColumn)expr.getRightArg()), filter);
    4.84 +//			}
    4.85 +//			else if(expr.getRightArg() instanceof GeneralDBURIColumn) //case met in transform!
    4.86 +//			{
    4.87 +//				filter.keepSRID_part1();
    4.88 +//				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
    4.89 +//				filter.keepSRID_part2();
    4.90 +//				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
    4.91 +//				filter.keepSRID_part3();
    4.92 +//			}
    4.93 +			else if(expr.getRightArg() instanceof GeneralDBDateTimeColumn)
    4.94  			{
    4.95 -				append(((GeneralDBDoubleValue)expr.getRightArg()), filter);
    4.96 -			}
    4.97 -			else if(expr.getRightArg() instanceof GeneralDBNumericColumn) //case met in buffer!
    4.98 -			{
    4.99 -				append(((GeneralDBNumericColumn)expr.getRightArg()), filter);
   4.100 -			}
   4.101 -			else if(expr.getRightArg() instanceof GeneralDBURIColumn) //case met in transform!
   4.102 -			{
   4.103 -				filter.keepSRID_part1();
   4.104 -				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
   4.105 -				filter.keepSRID_part2();
   4.106 -				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
   4.107 -				filter.keepSRID_part3();
   4.108 -			}
   4.109 -			//case met in buffer when in select -> buffer(?spatial,?thematic)
   4.110 -			else if(expr.getRightArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getRightArg()).isSpatial())
   4.111 -			{	// TODO auto den einai swsto giati mporei na mhn ginei apply 
   4.112 -				// mono se dateTime values
   4.113 -				filter.append(" extract(epoch from ");
   4.114 -				append(((GeneralDBLabelColumn)expr.getRightArg()),filter);
   4.115 -				filter.append("::timestamp) ");
   4.116 -				
   4.117 +				append(((GeneralDBDateTimeColumn)expr.getRightArg()),filter);	
   4.118  			}
   4.119  			else
   4.120  			{