Strabon

changeset 989:ee4984f7a3ca

fixed bug where a not implemented extension function would make Strabon throw a NULL pointer exception. Now we get away with it through a warning.
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Apr 05 19:02:09 2013 +0300 (2013-04-05)
parents 3e3bf4aaa021
children 1f615604f096
files generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Apr 05 18:41:16 2013 +0300
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Apr 05 19:02:09 2013 +0300
     1.3 @@ -47,16 +47,16 @@
     1.4  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.CrossesFunc;
     1.5  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.DisjointFunc;
     1.6  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.EqualsFunc;
     1.7 -import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.WithinFunc;
     1.8  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.IntersectsFunc;
     1.9  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.LeftFunc;
    1.10  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.OverlapsFunc;
    1.11  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.RightFunc;
    1.12  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.TouchesFunc;
    1.13 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.WithinFunc;
    1.14  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbContainsFunc;
    1.15  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbEqualsFunc;
    1.16 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbIntersectsFunc;
    1.17  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbWithinFunc;
    1.18 -import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbIntersectsFunc;
    1.19  import org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl;
    1.20  import org.openrdf.query.algebra.evaluation.iterator.OrderIterator;
    1.21  import org.openrdf.query.algebra.evaluation.iterator.StSPARQLGroupIterator;
    1.22 @@ -115,7 +115,7 @@
    1.23   */
    1.24  public abstract class GeneralDBEvaluation extends EvaluationStrategyImpl {
    1.25  
    1.26 -	public Logger logger;
    1.27 +	private static final Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.evaluation.GeneralDBEvaluation.class);;
    1.28  
    1.29  	protected GeneralDBQueryBuilderFactory factory;
    1.30  
    1.31 @@ -143,11 +143,9 @@
    1.32  	//	private HashMap<String, Integer> boolPropertiesIndexesAndNames = new HashMap<String, Integer>();
    1.33  	//	private HashMap<String, Integer> stringPropertiesIndexesAndNames = new HashMap<String, Integer>();
    1.34  
    1.35 -	public GeneralDBEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset,
    1.36 -			IdSequence ids)
    1.37 +	public GeneralDBEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset, IdSequence ids)
    1.38  	{
    1.39  		super(new GeneralDBTripleSource(triples), dataset);
    1.40 -		this.logger = LoggerFactory.getLogger(GeneralDBEvaluation.class);
    1.41  		this.factory = factory;
    1.42  		this.triples = triples;
    1.43  		this.vf = triples.getValueFactory();
    1.44 @@ -155,9 +153,7 @@
    1.45  	}
    1.46  
    1.47  	@Override
    1.48 -	public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr,
    1.49 -			BindingSet bindings)
    1.50 -	throws QueryEvaluationException
    1.51 +	public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException
    1.52  	{
    1.53  		if (expr instanceof GeneralDBSelectQuery)
    1.54  			return evaluate((GeneralDBSelectQuery)expr, bindings);
    1.55 @@ -171,8 +167,7 @@
    1.56  	}
    1.57  	
    1.58  	@Override
    1.59 -	public Value evaluate(ValueExpr expr, BindingSet bindings)
    1.60 -	throws ValueExprEvaluationException, QueryEvaluationException
    1.61 +	public Value evaluate(ValueExpr expr, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException
    1.62  	{
    1.63  		if (expr instanceof Var) {
    1.64  			return evaluate((Var)expr, bindings);
    1.65 @@ -250,6 +245,11 @@
    1.66  		// get the function corresponding to the function call
    1.67  		Function function = FunctionRegistry.getInstance().get(fc.getURI());
    1.68  		
    1.69 +		if (function == null) {
    1.70 +			logger.warn("[Strabon.evaluation(FunctionCall)] Extension function <{}> is not supported.", fc.getURI());
    1.71 +			return null;
    1.72 +		}
    1.73 +		
    1.74  		// get the first argument of the function call
    1.75  		ValueExpr left = fc.getArgs().get(0);
    1.76  
    1.77 @@ -479,7 +479,7 @@
    1.78  				return function.evaluate(tripleSource.getValueFactory(), argValues);
    1.79  			}
    1.80  		} catch (Exception e) {
    1.81 -			e.printStackTrace();
    1.82 +			logger.error("Strabon.evaluate(FunctionCall)] Error during evaluation of extension function.", e);
    1.83  			return null;
    1.84  		}
    1.85  
     2.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java	Fri Apr 05 18:41:16 2013 +0300
     2.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java	Fri Apr 05 19:02:09 2013 +0300
     2.3 @@ -29,6 +29,7 @@
     2.4  import org.openrdf.sail.rdbms.exceptions.RdbmsQueryEvaluationException;
     2.5  import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException;
     2.6  import org.openrdf.sail.generaldb.schema.IdSequence;
     2.7 +import org.slf4j.Logger;
     2.8  import org.slf4j.LoggerFactory;
     2.9  
    2.10  /**
    2.11 @@ -40,12 +41,11 @@
    2.12   */
    2.13  public class PostGISEvaluation extends GeneralDBEvaluation {
    2.14  
    2.15 +	private static final Logger logger = LoggerFactory.getLogger(org.openrdf.sail.postgis.evaluation.PostGISEvaluation.class);
    2.16  
    2.17 -	public PostGISEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset,
    2.18 -			IdSequence ids)
    2.19 +	public PostGISEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset, IdSequence ids)
    2.20  	{
    2.21  		super(factory, triples, dataset, ids);
    2.22 -		logger = LoggerFactory.getLogger(PostGISEvaluation.class);
    2.23  		this.factory = factory;
    2.24  	}
    2.25  
    2.26 @@ -70,7 +70,7 @@
    2.27  				result.setBindings(bindings);
    2.28  				result.setValueFactory(vf);
    2.29  				result.setIdSequence(ids);
    2.30 -				//XXX addition
    2.31 +				// addition
    2.32  				result.setGeoNames(this.geoNames);
    2.33  				result.setConstructIndexesAndNames(this.constructIndexesAndNames);
    2.34