[Mulgara-dev] patch for REST TQL subquery problems

David Smith DMS at viewpointusa.com
Sat Jan 16 18:35:49 UTC 2010


I believe this fixes the problem with using TQL REST endpoint with
queries containing SUBQUERY

Basically the old code was (incorrectly) referring to the original
answer instead of the answer parameter.
Also, needed to form the XML correctly.

BTW, I'm in the process of switching our system from SOAP to TQL
endpoint and am seeing 5+ times speedup 
AND appears to scale better when under load.  Nice.

Dave S



Index: StreamedTqlXMLAnswer.java
===================================================================
--- StreamedTqlXMLAnswer.java	(revision 1888)
+++ StreamedTqlXMLAnswer.java	(working copy)
@@ -97,8 +97,11 @@
 
   /** {@inheritDoc} */
   protected void addResult(Answer a, int indent) throws
TuplesException, IOException {
+    int width = (a != null) ? a.getNumberOfVariables() : 0;
+    Variable[] vars = (a != null) ? a.getVariables() : null;
+
     s.append(i(indent + 2)).append("<solution>");
-    for (int c = 0; c < width; c++) addBinding(vars[c],
answer.getObject(c), indent);
+    for (int c = 0; c < width; c++) addBinding(vars[c], a.getObject(c),
indent);
     s.append(i(indent + 2)).append("</solution>");
   }
 
@@ -127,8 +130,10 @@
         addLiteral((Literal)value);
         s.append("</").append(var.getName()).append(">");
       } else if (value instanceof Answer) {
+		s.append(">");
         addHeader((Answer)value, indent + 4);
         addResults((Answer)value, indent + 4);
+        s.append("</").append(var.getName()).append(">");
       } else throw new IllegalArgumentException("Unable to create a
SPARQL response with an answer containing: " +
value.getClass().getSimpleName());
     }
   }

This E-Mail may contain confidential and privileged information. It is intended solely for the recipient(s) indicated. Any review, use, or distribution by anyone other than the intended recipient(s) is strictly prohibited. If you have received this E-Mail in error or are not the intended recipient, please notify the sender and delete all copies immediately.



More information about the Mulgara-dev mailing list