jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1495839 - /jena/trunk/jena-text/src/main/java/org/apache/jena/query/text/QueryPF.java
Date Sun, 23 Jun 2013 16:31:28 GMT
Author: andy
Date: Sun Jun 23 16:31:28 2013
New Revision: 1495839

URL: http://svn.apache.org/r1495839
Log:
Add "explain" logging.

Modified:
    jena/trunk/jena-text/src/main/java/org/apache/jena/query/text/QueryPF.java

Modified: jena/trunk/jena-text/src/main/java/org/apache/jena/query/text/QueryPF.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-text/src/main/java/org/apache/jena/query/text/QueryPF.java?rev=1495839&r1=1495838&r2=1495839&view=diff
==============================================================================
--- jena/trunk/jena-text/src/main/java/org/apache/jena/query/text/QueryPF.java (original)
+++ jena/trunk/jena-text/src/main/java/org/apache/jena/query/text/QueryPF.java Sun Jun 23
16:31:28 2013
@@ -38,6 +38,7 @@ import com.hp.hpl.jena.sparql.engine.Que
 import com.hp.hpl.jena.sparql.engine.binding.Binding ;
 import com.hp.hpl.jena.sparql.engine.iterator.QueryIterExtendByVar ;
 import com.hp.hpl.jena.sparql.engine.iterator.QueryIterSlice ;
+import com.hp.hpl.jena.sparql.mgt.Explain ;
 import com.hp.hpl.jena.sparql.pfunction.PropFuncArg ;
 import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionBase ;
 import com.hp.hpl.jena.sparql.util.IterLib ;
@@ -125,10 +126,9 @@ public class QueryPF extends PropertyFun
 
         // ----
 
-        QueryIterator qIter = (Var.isVar(s)) ? variableSubject(binding, s, match, execCxt)
: concreteSubject(binding,
-                                                                                        
                    s, match,
-                                                                                        
                    execCxt) ;
-
+        QueryIterator qIter = (Var.isVar(s)) 
+            ? variableSubject(binding, s, match, execCxt) 
+            : concreteSubject(binding, s, match, execCxt) ;
         if (match.getLimit() >= 0)
             qIter = new QueryIterSlice(qIter, 0, match.getLimit(), execCxt) ;
         return qIter ;
@@ -136,7 +136,7 @@ public class QueryPF extends PropertyFun
 
     private QueryIterator variableSubject(Binding binding, Node s, StrMatch match, ExecutionContext
execCxt) {
         Var v = Var.alloc(s) ;
-        List<Node> r = query(match.getQueryString(), match.getLimit()) ;
+        List<Node> r = query(match.getQueryString(), match.getLimit(), execCxt) ;
         // Make distinct. Note interaction with limit is imperfect
         r = Iter.iter(r).distinct().toList() ;
         QueryIterator qIter = new QueryIterExtendByVar(binding, v, r.iterator(), execCxt)
;
@@ -154,28 +154,28 @@ public class QueryPF extends PropertyFun
         // Restrict to matching and entity field be right.
         String qs = match.getQueryString() ;
         if ( false ) {
-            // This should work but it doesn't
+            // This should work but it doesn't. Why?
             String escaped = QueryParser.escape(uri) ;
             String qs2 = server.getDocDef().getEntityField() + ":" + escaped ;
             qs = qs2 + " AND " + qs ;
-            List<Node> x = query(qs, 1) ;
+            List<Node> x = query(qs, 1, execCxt) ;
             if (x == null || x.isEmpty())
                 return IterLib.noResults(execCxt) ;
             else
                 return IterLib.result(binding, execCxt) ;
         }
         // Crude.
-        List<Node> x = query(qs, -1) ;
+        List<Node> x = query(qs, -1, execCxt) ;
         if ( x == null || ! x.contains(s) )
             return IterLib.noResults(execCxt) ;
         else
             return IterLib.result(binding, execCxt) ;
     }
 
-    private List<Node> query(String queryString, int limit) {
-        // Explain
-        if ( log.isInfoEnabled())
-            log.info("Text query: {} ({})", queryString,limit) ;
+    private List<Node> query(String queryString, int limit, ExecutionContext execCxt)
{
+        Explain.explain(execCxt.getContext(), "Text query: "+queryString) ;
+        if ( log.isDebugEnabled())
+            log.debug("Text query: {} ({})", queryString,limit) ;
         return server.query(queryString, limit) ;
     }
     



Mime
View raw message