From: <jer...@us...> - 2013-10-09 23:22:47
|
Revision: 7444 http://bigdata.svn.sourceforge.net/bigdata/?rev=7444&view=rev Author: jeremy_carroll Date: 2013-10-09 23:22:40 +0000 (Wed, 09 Oct 2013) Log Message: ----------- tests and fixes for trac 736 on MIN and MAX aggregate functions Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MAX.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MIN.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.srx branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min-max.ttl branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.srx Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MAX.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MAX.java 2013-10-09 20:41:28 UTC (rev 7443) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MAX.java 2013-10-09 23:22:40 UTC (rev 7444) @@ -32,6 +32,7 @@ import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IValueExpression; import com.bigdata.bop.aggregate.AggregateBase; +import com.bigdata.bop.solutions.IVComparator; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.constraints.CompareBOp; import com.bigdata.rdf.internal.constraints.INeedsMaterialization; @@ -57,6 +58,8 @@ * */ private static final long serialVersionUID = 1L; + + private static IVComparator comparator = new IVComparator(); public MAX(MAX op) { super(op); @@ -121,15 +124,7 @@ } else { - /** - * FIXME This needs to use the ordering define by ORDER_BY. The - * CompareBOp imposes the ordering defined for the "<" operator - * which is less robust and will throw a type exception if you - * attempt to compare unlike Values. - * - * @see https://sourceforge.net/apps/trac/bigdata/ticket/300#comment:5 - */ - if (CompareBOp.compare(iv, max, CompareOp.GT)) { + if (comparator.compare(iv, max)>0) { max = iv; Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MIN.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MIN.java 2013-10-09 20:41:28 UTC (rev 7443) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/bop/rdf/aggregate/MIN.java 2013-10-09 23:22:40 UTC (rev 7444) @@ -35,6 +35,7 @@ import com.bigdata.bop.IValueExpression; import com.bigdata.bop.aggregate.AggregateBase; import com.bigdata.bop.aggregate.IAggregate; +import com.bigdata.bop.solutions.IVComparator; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.constraints.CompareBOp; import com.bigdata.rdf.internal.constraints.INeedsMaterialization; @@ -56,12 +57,15 @@ public class MIN extends AggregateBase<IV> implements INeedsMaterialization{ // private static final transient Logger log = Logger.getLogger(MIN.class); + /** * */ private static final long serialVersionUID = 1L; + private static IVComparator comparator = new IVComparator(); + public MIN(MIN op) { super(op); } @@ -125,15 +129,7 @@ } else { - /** - * FIXME This needs to use the ordering define by ORDER_BY. The - * CompareBOp imposes the ordering defined for the "<" operator - * which is less robust and will throw a type exception if you - * attempt to compare unlike Values. - * - * @see https://sourceforge.net/apps/trac/bigdata/ticket/300#comment:5 - */ - if (CompareBOp.compare(iv, min, CompareOp.LT)) { + if (comparator.compare(iv, min)<0) { min = iv; Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java 2013-10-09 20:41:28 UTC (rev 7443) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java 2013-10-09 23:22:40 UTC (rev 7444) @@ -253,4 +253,28 @@ } + + public void test_ticket_min736() throws Exception { + + new TestHelper("aggregate-min",// testURI, + "aggregate-min.rq",// queryFileURL + "aggregate-min-max.ttl",// dataFileURL + "aggregate-min.srx",// resultFileURL + false, // laxCardinality + true // checkOrder + ).runTest(); + + } + + public void test_ticket_max736() throws Exception { + + new TestHelper("aggregate-max",// testURI, + "aggregate-max.rq",// queryFileURL + "aggregate-min-max.ttl",// dataFileURL + "aggregate-max.srx",// resultFileURL + false, // laxCardinality + true // checkOrder + ).runTest(); + + } } Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.rq 2013-10-09 23:22:40 UTC (rev 7444) @@ -0,0 +1,5 @@ +SELECT (MAX(?o) AS ?m) +WHERE { + ?s ?p ?o +} + Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.srx =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.srx (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-max.srx 2013-10-09 23:22:40 UTC (rev 7444) @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<sparql + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:xs="http://www.w3.org/2001/XMLSchema#" + xmlns="http://www.w3.org/2005/sparql-results#" > + <head> + <variable name="m"/> + </head> + <results> + <result> + <binding name="m"> + <literal datatype="http://www.w3.org/2001/XMLSchema#integer">3</literal> + </binding> + </result> + </results> +</sparql> Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min-max.ttl =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min-max.ttl (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min-max.ttl 2013-10-09 23:22:40 UTC (rev 7444) @@ -0,0 +1,7 @@ +@prefix : <http://example/> . + +:x1 :p 1.5 . +:x1 :p 3 . +:x1 :p :x2 . + + Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.rq 2013-10-09 23:22:40 UTC (rev 7444) @@ -0,0 +1,4 @@ +SELECT (MIN(?o) AS ?m) +WHERE { + ?s ?p ?o +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.srx =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.srx (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/aggregate-min.srx 2013-10-09 23:22:40 UTC (rev 7444) @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<sparql + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:xs="http://www.w3.org/2001/XMLSchema#" + xmlns="http://www.w3.org/2005/sparql-results#" > + <head> + <variable name="m"/> + </head> + <results> + <result> + <binding name="m"><uri>http://example/x2</uri></binding> + </result> + </results> +</sparql> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |