Strabon

changeset 54:b678ff809288

merge
author Giorgos Garbis <ggarbis@di.uoa.gr>
date Wed Mar 14 17:02:40 2012 +0200 (2012-03-14)
parents 24eb0fafb8dd 17c697469b47
children 6ac1b8837a6a
files
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java	Wed Mar 14 17:00:55 2012 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java	Wed Mar 14 17:02:40 2012 +0200
     1.3 @@ -94,21 +94,21 @@
     1.4  	 *--------------*/
     1.5  
     1.6  	public StSPARQLGroupIterator(EvaluationStrategy strategy, Group group, BindingSet parentBindings)
     1.7 -			throws QueryEvaluationException
     1.8 -			{
     1.9 +		throws QueryEvaluationException
    1.10 +	{
    1.11  		this.strategy = strategy;
    1.12  		this.group = group;
    1.13  		this.parentBindings = parentBindings;
    1.14  		super.setIterator(createIterator());
    1.15 -			}
    1.16 +	}
    1.17  
    1.18  	/*---------*
    1.19  	 * Methods *
    1.20  	 *---------*/
    1.21  
    1.22  	private Iterator<BindingSet> createIterator()
    1.23 -			throws QueryEvaluationException
    1.24 -			{
    1.25 +		throws QueryEvaluationException
    1.26 +	{
    1.27  		Collection<Entry> entries = buildEntries();
    1.28  		Collection<BindingSet> bindingSets = new LinkedList<BindingSet>();
    1.29  
    1.30 @@ -141,11 +141,11 @@
    1.31  		}
    1.32  
    1.33  		return bindingSets.iterator();
    1.34 -			}
    1.35 +	}
    1.36  
    1.37  	private Collection<Entry> buildEntries()
    1.38 -			throws QueryEvaluationException
    1.39 -			{
    1.40 +		throws QueryEvaluationException
    1.41 +	{
    1.42  		CloseableIteration<BindingSet, QueryEvaluationException> iter;
    1.43  		iter = strategy.evaluate(group.getArg(), parentBindings);
    1.44  
    1.45 @@ -183,7 +183,7 @@
    1.46  			iter.close();
    1.47  		}
    1.48  
    1.49 -			}
    1.50 +	}
    1.51  
    1.52  	/**
    1.53  	 * A unique key for a set of existing bindings.
    1.54 @@ -244,8 +244,8 @@
    1.55  		private Map<FunctionCall, Geometry> spatialAggregatesResult;
    1.56  
    1.57  		public Entry(BindingSet prototype)
    1.58 -				throws ValueExprEvaluationException, QueryEvaluationException
    1.59 -				{
    1.60 +			throws ValueExprEvaluationException, QueryEvaluationException
    1.61 +		{
    1.62  			this.prototype = prototype;
    1.63  			this.aggregates = new LinkedHashMap<String, Aggregate>();
    1.64  			this.spatialAggregates = new LinkedHashMap<String, FunctionCall>();
    1.65 @@ -286,15 +286,15 @@
    1.66  					}
    1.67  				}
    1.68  			}
    1.69 -				}
    1.70 +		}
    1.71  
    1.72  		public BindingSet getPrototype() {
    1.73  			return prototype;
    1.74  		}
    1.75  
    1.76  		public void addSolution(BindingSet bindingSet)
    1.77 -				throws QueryEvaluationException
    1.78 -				{
    1.79 +			throws QueryEvaluationException
    1.80 +		{
    1.81  			for (Aggregate aggregate : aggregates.values()) {
    1.82  				aggregate.processAggregate(bindingSet);
    1.83  			}
    1.84 @@ -302,11 +302,11 @@
    1.85  				processSpatialAggregate(spatialAggregate, bindingSet);
    1.86  				//spatialAggregates.processAggregate(bindingSet);
    1.87  			}
    1.88 -				}
    1.89 +		}
    1.90  
    1.91  		public void bindSolution(QueryBindingSet sol)
    1.92 -				throws QueryEvaluationException
    1.93 -				{
    1.94 +			throws QueryEvaluationException
    1.95 +		{
    1.96  			for (String name : aggregates.keySet()) {
    1.97  				try {
    1.98  					Value value = aggregates.get(name).getValue();
    1.99 @@ -370,7 +370,7 @@
   1.100  
   1.101  
   1.102  
   1.103 -				}
   1.104 +		}
   1.105  
   1.106  		/**
   1.107  		 * XXX addition
   1.108 @@ -666,8 +666,8 @@
   1.109  		//		}
   1.110  
   1.111  		private Aggregate create(AggregateOperator operator)
   1.112 -				throws ValueExprEvaluationException, QueryEvaluationException
   1.113 -				{
   1.114 +			throws ValueExprEvaluationException, QueryEvaluationException
   1.115 +		{
   1.116  			if (operator instanceof Count) {
   1.117  				return new CountAggregate((Count)operator);
   1.118  			}
   1.119 @@ -690,7 +690,7 @@
   1.120  				return new ConcatAggregate((GroupConcat)operator);
   1.121  			}
   1.122  			return null;
   1.123 -				}
   1.124 +		}
   1.125  	}
   1.126  
   1.127  	private abstract class Aggregate {
   1.128 @@ -724,15 +724,15 @@
   1.129  		}
   1.130  
   1.131  		protected Value evaluate(BindingSet s)
   1.132 -				throws QueryEvaluationException
   1.133 -				{
   1.134 +			throws QueryEvaluationException
   1.135 +		{
   1.136  			try {
   1.137  				return strategy.evaluate(getArg(), s);
   1.138  			}
   1.139  			catch (ValueExprEvaluationException e) {
   1.140  				return null; // treat missing or invalid expressions as null
   1.141  			}
   1.142 -				}
   1.143 +		}
   1.144  	}
   1.145  
   1.146  	private class CountAggregate extends Aggregate {
   1.147 @@ -745,8 +745,8 @@
   1.148  
   1.149  		@Override
   1.150  		public void processAggregate(BindingSet s)
   1.151 -				throws QueryEvaluationException
   1.152 -				{
   1.153 +			throws QueryEvaluationException
   1.154 +		{
   1.155  			if (getArg() != null) {
   1.156  				Value value = evaluate(s);
   1.157  				if (value != null && distinct(value)) {
   1.158 @@ -756,7 +756,7 @@
   1.159  			else {
   1.160  				count++;
   1.161  			}
   1.162 -				}
   1.163 +		}
   1.164  
   1.165  		@Override
   1.166  		public Value getValue() {
   1.167 @@ -776,8 +776,8 @@
   1.168  
   1.169  		@Override
   1.170  		public void processAggregate(BindingSet s)
   1.171 -				throws QueryEvaluationException
   1.172 -				{
   1.173 +			throws QueryEvaluationException
   1.174 +		{
   1.175  			Value v = evaluate(s);
   1.176  			if (distinct(v)) {
   1.177  				if (min == null) {
   1.178 @@ -787,7 +787,7 @@
   1.179  					min = v;
   1.180  				}
   1.181  			}
   1.182 -				}
   1.183 +		}
   1.184  
   1.185  		@Override
   1.186  		public Value getValue() {
   1.187 @@ -807,8 +807,8 @@
   1.188  
   1.189  		@Override
   1.190  		public void processAggregate(BindingSet s)
   1.191 -				throws QueryEvaluationException
   1.192 -				{
   1.193 +			throws QueryEvaluationException
   1.194 +		{
   1.195  			Value v = evaluate(s);
   1.196  			if (distinct(v)) {
   1.197  				if (max == null) {
   1.198 @@ -818,7 +818,7 @@
   1.199  					max = v;
   1.200  				}
   1.201  			}
   1.202 -				}
   1.203 +		}
   1.204  
   1.205  		@Override
   1.206  		public Value getValue() {
   1.207 @@ -838,8 +838,8 @@
   1.208  
   1.209  		@Override
   1.210  		public void processAggregate(BindingSet s)
   1.211 -				throws QueryEvaluationException
   1.212 -				{
   1.213 +			throws QueryEvaluationException
   1.214 +		{
   1.215  			if (typeError != null) {
   1.216  				// halt further processing if a type error has been raised
   1.217  				return;
   1.218 @@ -862,18 +862,18 @@
   1.219  					typeError = new ValueExprEvaluationException("not a number: " + v);
   1.220  				}
   1.221  			}
   1.222 -				}
   1.223 +		}
   1.224  
   1.225  		@Override
   1.226  		public Value getValue()
   1.227 -				throws ValueExprEvaluationException
   1.228 -				{
   1.229 +			throws ValueExprEvaluationException
   1.230 +		{
   1.231  			if (typeError != null) {
   1.232  				throw typeError;
   1.233  			}
   1.234  
   1.235  			return sum;
   1.236 -				}
   1.237 +		}
   1.238  	}
   1.239  
   1.240  	private class AvgAggregate extends Aggregate {
   1.241 @@ -890,8 +890,8 @@
   1.242  
   1.243  		@Override
   1.244  		public void processAggregate(BindingSet s)
   1.245 -				throws QueryEvaluationException
   1.246 -				{
   1.247 +			throws QueryEvaluationException
   1.248 +		{
   1.249  			if (typeError != null) {
   1.250  				// Prevent calculating the aggregate further if a type error has
   1.251  				// occured.
   1.252 @@ -919,12 +919,12 @@
   1.253  					typeError = new ValueExprEvaluationException("not a number: " + v);
   1.254  				}
   1.255  			}
   1.256 -				}
   1.257 +		}
   1.258  
   1.259  		@Override
   1.260  		public Value getValue()
   1.261 -				throws ValueExprEvaluationException
   1.262 -				{
   1.263 +			throws ValueExprEvaluationException
   1.264 +		{
   1.265  			if (typeError != null) {
   1.266  				// a type error occurred while processing the aggregate, throw it
   1.267  				// now.
   1.268 @@ -937,7 +937,7 @@
   1.269  
   1.270  			Literal sizeLit = vf.createLiteral(count);
   1.271  			return MathUtil.compute(sum, sizeLit, MathOp.DIVIDE);
   1.272 -				}
   1.273 +		}
   1.274  	}
   1.275  
   1.276  	private class SampleAggregate extends Aggregate {
   1.277 @@ -950,12 +950,12 @@
   1.278  
   1.279  		@Override
   1.280  		public void processAggregate(BindingSet s)
   1.281 -				throws QueryEvaluationException
   1.282 -				{
   1.283 +			throws QueryEvaluationException
   1.284 +		{
   1.285  			if (sample == null) {
   1.286  				sample = evaluate(s);
   1.287  			}
   1.288 -				}
   1.289 +		}
   1.290  
   1.291  		@Override
   1.292  		public Value getValue() {
   1.293 @@ -971,25 +971,25 @@
   1.294  
   1.295  		public ConcatAggregate(GroupConcat groupConcatOp)
   1.296  				throws ValueExprEvaluationException, QueryEvaluationException
   1.297 -				{
   1.298 +		{
   1.299  			super(groupConcatOp);
   1.300  			ValueExpr separatorExpr = groupConcatOp.getSeparator();
   1.301  			if (separatorExpr != null) {
   1.302  				Value separatorValue = strategy.evaluate(separatorExpr, parentBindings);
   1.303  				separator = separatorValue.stringValue();
   1.304  			}
   1.305 -				}
   1.306 +		}
   1.307  
   1.308  		@Override
   1.309  		public void processAggregate(BindingSet s)
   1.310 -				throws QueryEvaluationException
   1.311 -				{
   1.312 +			throws QueryEvaluationException
   1.313 +		{
   1.314  			Value v = evaluate(s);
   1.315  			if (v != null && distinct(v)) {
   1.316  				concatenated.append(v.stringValue());
   1.317  				concatenated.append(separator);
   1.318  			}
   1.319 -				}
   1.320 +		}
   1.321  
   1.322  		@Override
   1.323  		public Value getValue() {