You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ca...@apache.org on 2011/08/13 20:13:41 UTC

svn commit: r1157404 - in /incubator/jena/Jena2/ARQ/trunk: src/com/hp/hpl/jena/sparql/engine/binding/ src/com/hp/hpl/jena/sparql/engine/iterator/ src/org/openjena/atlas/lib/ testing/ARQ/Optimization/

Author: castagna
Date: Sat Aug 13 18:13:40 2011
New Revision: 1157404

URL: http://svn.apache.org/viewvc?rev=1157404&view=rev
Log:
JENA-89 - Additional tests and bux fix. Patches from Andy applied, thanks (and apologies, lesson learned!). data-2.ttl was missing, but it was easy to create it.

Added:
    incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java   (with props)
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/data-2.ttl
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.srj
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-11.rq
Modified:
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/binding/BindingComparator.java
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/iterator/QueryIterTopN.java
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/manifest.ttl

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/binding/BindingComparator.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/binding/BindingComparator.java?rev=1157404&r1=1157403&r2=1157404&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/binding/BindingComparator.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/binding/BindingComparator.java Sat Aug 13 18:13:40 2011
@@ -6,6 +6,7 @@
 
 package com.hp.hpl.jena.sparql.engine.binding;
 
+import java.util.Collections ;
 import java.util.Iterator ;
 import java.util.List ;
 
@@ -26,7 +27,7 @@ import com.hp.hpl.jena.sparql.util.NodeU
 
 public class BindingComparator implements java.util.Comparator<Binding>
 {
-    List<SortCondition> conditions ;
+    private List<SortCondition> conditions ;
     private FunctionEnv env ;
     
     public BindingComparator(List<SortCondition> conditions, ExecutionContext execCxt)
@@ -40,6 +41,8 @@ public class BindingComparator implement
         conditions = _conditions ;
         this.env = new FunctionEnvBase();
     }
+    
+    public List<SortCondition> getConditions() { return Collections.unmodifiableList(conditions) ; } 
 
     // Compare bindings by iterating.
     // Node comparsion is:

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/iterator/QueryIterTopN.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/iterator/QueryIterTopN.java?rev=1157404&r1=1157403&r2=1157404&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/iterator/QueryIterTopN.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/engine/iterator/QueryIterTopN.java Sat Aug 13 18:13:40 2011
@@ -6,7 +6,10 @@ import java.util.Iterator ;
 import java.util.List ;
 import java.util.PriorityQueue ;
 
+import org.openjena.atlas.iterator.Iter ;
+import org.openjena.atlas.iterator.IteratorArray ;
 import org.openjena.atlas.iterator.IteratorDelayedInitialization ;
+import org.openjena.atlas.lib.ReverseComparator ;
 
 import com.hp.hpl.jena.query.Query ;
 import com.hp.hpl.jena.query.QueryExecException ;
@@ -19,6 +22,11 @@ import com.hp.hpl.jena.sparql.engine.bin
 public class QueryIterTopN extends QueryIterPlainWrapper
 {
 	private final QueryIterator embeddedIterator;      // Keep a record of the underlying source for .cancel.
+	/* We want to keep the N least elements (overall return is an ascending sequnce so limit+ascending = least).   
+	 * To do that we keep a priority heap of upto N eleemnts, ordered descending.
+	 * To keep another element, it must be less than the max so far.
+	 * This leaves the least N in the heap.    
+	 */
     private PriorityQueue<Binding> heap ;
     long limit ;
 	
@@ -30,6 +38,7 @@ public class QueryIterTopN extends Query
     public QueryIterTopN(QueryIterator qIter, Comparator<Binding> comparator, long numItems, ExecutionContext context)
     {
         super(null, context) ;
+        this.embeddedIterator = qIter;
         
         limit = numItems ;
         if ( limit == Query.NOLIMIT )
@@ -38,9 +47,16 @@ public class QueryIterTopN extends Query
         if ( limit < 0 )
             throw new QueryExecException("Negative LIMIT: "+limit) ;
         
-        this.embeddedIterator = qIter;
-        this.heap = new PriorityQueue<Binding>((int)numItems, comparator) ;
+        if ( limit == 0 )
+        {
+            // Keep Java happy. 
+            Iterator<Binding> iter0 = Iter.nullIterator() ; 
+            setIterator(iter0) ;
+            return ;
+        }
         
+        // Keep heap with maximum accessible. 
+        this.heap = new PriorityQueue<Binding>((int)numItems, new ReverseComparator<Binding>(comparator)) ;
         this.setIterator(sortTopN(qIter, comparator));
     }
 
@@ -51,7 +67,6 @@ public class QueryIterTopN extends Query
         super.requestCancel() ;
     }
     
-
     private Iterator<Binding> sortTopN(final QueryIterator qIter, final Comparator<Binding> comparator)
     {
         return new IteratorDelayedInitialization<Binding>() {
@@ -60,13 +75,17 @@ public class QueryIterTopN extends Query
             {
                 for ( ; qIter.hasNext() ; )
                 {
-                    Binding b = qIter.next() ;
+                    Binding binding = qIter.next() ;
                     if ( heap.size() < limit )
-                    	heap.add(b) ;
+                    	heap.add(binding) ;
                     else {
-                    	if ( comparator.compare(b, heap.peek()) < 0 ) {
-                    		heap.poll() ;
-                        	heap.add(b) ;
+                        Binding currentMaxLeastN = heap.peek() ;
+                        
+                    	if ( comparator.compare(binding, currentMaxLeastN) < 0 ) 
+                    	{
+                    	    // If binding is less than current Nth least ...
+                    		heap.poll() ;     // Drop Nth least.
+                        	heap.add(binding) ;
                     	}
                     }
                 }
@@ -74,7 +93,8 @@ public class QueryIterTopN extends Query
                 Binding[] y = heap.toArray(new Binding[]{}) ;
                 heap = null ;
                 Arrays.sort(y, comparator) ;
-                return Arrays.asList(y).iterator() ;
+                IteratorArray<Binding> iter = IteratorArray.create(y) ;
+                return iter ;
         	}
 		};
     }}

Added: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java (added)
+++ incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java Sat Aug 13 18:13:40 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openjena.atlas.lib;
+
+import java.util.Comparator ;
+
+/** Comparator that compares the other way round to it's sub-comparator */  
+public class ReverseComparator<T> implements Comparator<T>
+{
+    private final Comparator<T> comparator ;
+    
+    public ReverseComparator(Comparator<T> comparator)
+    {
+        this.comparator = comparator ;
+    }
+    
+    public int compare(T o1, T o2)
+    {
+        return -comparator.compare(o1, o2) ;
+    }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/org/openjena/atlas/lib/ReverseComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/data-2.ttl
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/data-2.ttl?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/data-2.ttl (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/data-2.ttl Sat Aug 13 18:13:40 2011
@@ -0,0 +1,26 @@
+@prefix : <http://example/> .
+
+:x1 :p 1 .
+:x2 :p 2 .
+:x3 :p 3 .
+:x3a :p 3 .
+:x4 :p 4 .
+:x5 :p 5 .
+:x6 :p 6 .
+:x6a :p 6 .
+:x7 :p 7 .
+:x8 :p 8 .
+:x9 :p 9 .
+:x10 :p 10 .
+:x11 :p 11 .
+:x12 :p 12 .
+:x13 :p 13 .
+:x14 :p 14 .
+:x14a :p 14 .
+:x15 :p 15 .
+:x16 :p 16 .
+:x17 :p 17 .
+:x18 :p 18 .
+:x19 :p 19 .
+:x19a :p 19 .
+:x20 :p 20 .
\ No newline at end of file

Modified: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/manifest.ttl
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/manifest.ttl?rev=1157404&r1=1157403&r2=1157404&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/manifest.ttl (original)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/manifest.ttl Sat Aug 13 18:13:40 2011
@@ -150,4 +150,84 @@
               qt:data   <data-1.ttl> ] ;
         mf:result  <opt-sameTerm-10.srx>
       ]
+
+      [  mf:name    "opt-top-01" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-01.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-01.srj>
+      ]
+
+      [  mf:name    "opt-top-02" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-02.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-02.srj>
+      ]
+
+      [  mf:name    "opt-top-03" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-03.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-03.srj>
+      ]
+
+      [  mf:name    "opt-top-04" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-04.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-04.srj>
+      ]
+
+     [  mf:name    "opt-top-05" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-05.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-05.srj>
+      ]
+
+      [  mf:name    "opt-top-06" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-06.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-06.srj>
+      ]
+
+      [  mf:name    "opt-top-07" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-07.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-07.srj>
+      ]
+
+      [  mf:name    "opt-top-08" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-08.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-08.srj>
+      ]
+
+      [  mf:name    "opt-top-09" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-09.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-09.srj>
+      ]
+
+      [  mf:name    "opt-top-10" ;
+         rdf:type   mfx:TestQuery ; 
+         mf:action
+            [ qt:query  <opt-top-10.rq> ;
+              qt:data   <data-2.ttl> ] ;
+        mf:result  <opt-top-10.srj>
+      ]
     ).

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT * 
+{ ?x :p ?v } 
+ORDER BY ASC(?v)
+LIMIT 5

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-01.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,29 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT * 
+{ ?x :p ?v } 
+ORDER BY DESC(?v)
+LIMIT 5

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-02.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,29 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x20" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "20" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x18" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "18" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x17" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "17" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,7 @@
+PREFIX : <http://example/>
+
+SELECT * 
+{ ?x :p ?v } 
+ORDER BY ASC(?v)
+# Greater than the limit of using a bounded prirotiy queue.
+LIMIT 50000

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-03.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,105 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x5" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "5" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x7" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "7" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x8" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "8" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x9" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "9" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x10" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "10" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x11" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "11" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x12" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "12" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x13" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "13" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x15" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "15" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x16" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "16" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x17" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "17" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x18" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "18" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x20" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "20" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT * 
+{ ?x :p ?v } 
+ORDER BY DESC(?v)
+LIMIT 50000

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-04.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,105 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x20" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "20" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x18" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "18" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x17" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "17" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x16" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "16" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x15" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "15" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x13" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "13" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x12" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "12" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x11" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "11" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x10" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "10" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x9" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "9" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x8" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "8" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x7" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "7" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x5" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "5" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT DISTINCT * 
+{ ?x :p ?v } 
+ORDER BY ASC(?v)
+LIMIT 5

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-05.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,29 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT DISTINCT * 
+{ ?x :p ?v } 
+ORDER BY DESC(?v)
+LIMIT 5

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-06.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,29 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x20" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "20" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x18" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "18" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x17" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "17" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,7 @@
+PREFIX : <http://example/>
+
+SELECT DISTINCT * 
+{ ?x :p ?v } 
+ORDER BY ASC(?v)
+# Greater than the limit of using a bounded prirotiy queue.
+LIMIT 50000

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-07.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,105 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x5" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "5" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x7" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "7" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x8" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "8" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x9" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "9" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x10" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "10" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x11" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "11" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x12" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "12" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x13" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "13" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x15" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "15" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x16" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "16" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x17" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "17" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x18" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "18" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x20" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "20" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT DISTINCT * 
+{ ?x :p ?v } 
+ORDER BY DESC(?v)
+LIMIT 50000

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-08.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,105 @@
+{
+  "head": {
+    "vars": [ "x" , "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x20" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "20" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x19a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "19" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x18" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "18" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x17" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "17" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x16" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "16" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x15" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "15" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x14a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "14" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x13" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "13" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x12" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "12" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x11" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "11" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x10" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "10" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x9" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "9" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x8" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "8" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x7" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "7" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x6a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "6" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x5" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "5" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" } ,
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT ?x
+{ ?x :p ?v } 
+ORDER BY ?v
+LIMIT 5

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-09.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,24 @@
+{
+  "head": {
+    "vars": [ "x" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "x": { "type": "uri" , "value": "http://example/x1" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x2" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x3a" }
+      } ,
+      {
+        "x": { "type": "uri" , "value": "http://example/x4" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,6 @@
+PREFIX : <http://example/>
+
+SELECT DISTINCT ?v
+{ ?x :p ?v } 
+ORDER BY ?v
+LIMIT 5

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.srj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.srj?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.srj (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-10.srj Sat Aug 13 18:13:40 2011
@@ -0,0 +1,24 @@
+{
+  "head": {
+    "vars": [ "v" ]
+  } ,
+  "results": {
+    "bindings": [
+      {
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "1" }
+      } ,
+      {
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "2" }
+      } ,
+      {
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "3" }
+      } ,
+      {
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "4" }
+      } ,
+      {
+        "v": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "5" }
+      }
+    ]
+  }
+}

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-11.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-11.rq?rev=1157404&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-11.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/Optimization/opt-top-11.rq Sat Aug 13 18:13:40 2011
@@ -0,0 +1,7 @@
+PREFIX : <http://example/>
+
+SELECT DISINCT ?x 
+{ ?x :p ?v } 
+ORDER BY ASC(?v)
+# Greater than the limit of using a bounded prirotiy queue.
+LIMIT 50000