In a number of other sparql implementations, I use bind as a way to produce a 
result set that has the fixed subject listed as a column.

That is, the desired result is a ?s column with the same value repeated for 
each triple, followed by the usual columns for the ?p and ?o values for each 
triple.

If I try to use bind in marklogic, the query times out. Using a values 
statement instead produces the desired result instantly. Also, limiting the 
size of the result, up to a point, does allow the bind version to complete.

Something about bind is following a very different code path, it seems.

## query
select * {
#  bind (      ## uncomment to use bind, which times out
#  values ?s {     ## uncomment to use values, which produces the expected 
result right away
  <http://bio2rdf.org/ncbigene:255738>   ## ?s as a literal, the result set 
returns just two columns, ?p and ?o
#    }  ?s   ## uncomment to use values
#    as ?s) ?s    ## uncomment to use bind
?p ?o .
  }
# limit 14   ## literal version returns 14 rows, bind version still times out 
when limit set to match
# limit 3     ## set the limit small and bind version does return – results are 
part of the full set
# limit 5     ## still returns, but takes much longer than limit 3
# limit 10   ## times out

2016-08-01 16:17:03.130 Info: App-Services: <error:error 
xsi:schemaLocation="http://marklogic.com/xdmp/error error.xsd" 
xmlns:error="http://marklogic.com/xdmp/error"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
2016-08-01 16:17:03.130 Info: App-Services:   
<error:code>XDMP-EXTIME</error:code>
2016-08-01 16:17:03.130 Info: App-Services:   <error:name/>
2016-08-01 16:17:03.130 Info: App-Services:   
<error:xquery-version>1.0-ml</error:xquery-version>
2016-08-01 16:17:03.130 Info: App-Services:   <error:message>Time limit 
exceeded</error:message>
2016-08-01 16:17:03.130 Info: App-Services:   <error:format-string>XDMP-EXTIME: 
try { let $_ := sec:secure-x-frame() let $_ := 
sec:secure-request-params("evaler") let $set := 
amped-common:appservices-expire-headers() let $params-map := 
rest:process-request($http-opts) let $action := map:get($params-map, "action") 
let $qid := map:get($params-map, "qid") let $name := map:get($params-map, 
"name") let $active := map:get($params-map, "active") let $focus := 
map:get($params-map, "focus") let $mode := fn:lower-case(map:get($params-map, 
"mode")) let $content-source := map:get($params-map, "content-source") let 
$wsid := map:get($params-map, "wsid") let $sid := map:get($params-map, "sid") 
let $dbid := map:get($params-map, "dbid") let $crid := map:get($params-map, 
"crid") let $query-type := map:get($params-map, "querytype") let $query-text := 
xdmp:get-request-body("text") let $sql-query := "import module namespace 
amped-qconsole = &amp;quot;http://marklogic...."; let $sparql-query := "import 
module namespace amped-qconsole = &amp;quot;http://marklogic...."; let 
$sparql-update-query := "import module namespace amped-qconsole = 
&amp;quot;http://marklogic...."; return if (fn:exists($qid) and 
fn:not(qconsole-model:is-query-found($qid))) then let $msg := fn:concat("Query 
with this ID ", $qid, " does not exist") let $code := 
xdmp:set-response-code(404, $msg) return 
json:transform-to-json-string(&lt;error&gt;{ $msg }&lt;/error&gt;, 
json:config("custom")) else let $query := $query-text let $new-query := if 
(fn:empty($qid) and $wsid) then let $new-query := 
amped-qconsole:qconsole-eval("import module namespace qconsole-model = 
&amp;quot;http://marklogic....";, (fn:QName("","wsid"), $wsid), ()) return 
xdmp:set($qid, $new-query/id) else () let $eval-opts := if ($sid or $dbid) then 
amped-qconsole:qconsole-get-eval-options($sid, $dbid, fn:true()) else () let 
$result := if ($action eq "eval") then if ($query-type eq "xquery") then 
(qceval:do-eval($qid, $query, "", $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else if ($query-type 
eq "sql") then (qceval:do-eval($qid, $query, $sql-query, $eval-opts, 
$query-type), qceval:replica-database-set-response-message($sid, $dbid)) else 
if ($query-type eq "sparql") then (qceval:do-eval($qid, $query, $sparql-query, 
$eval-opts, $query-type), qceval:replica-database-set-response-message($sid, 
$dbid)) else if ($query-type eq "sparql-update") then (qceval:do-eval($qid, 
$query, $sparql-update-query, $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else () else if 
($action eq "profile") then if ($query-type eq "xquery") then 
(qceval:do-profile($qid, $query, "", $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else if ($query-type 
eq "sql") then (qceval:do-profile($qid, $query, $sql-query, $eval-opts, 
$query-type), qceval:replica-database-set-response-message($sid, $dbid)) else 
if ($query-type eq "sparql") then (qceval:do-profile($qid, $query, 
$sparql-query, $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else if ($query-type 
eq "sparql-update") then (qceval:do-profile($qid, $query, $sparql-update-query, 
$eval-opts, $query-type), qceval:replica-database-set-response-message($sid, 
$dbid)) else () else if ($action eq "cancel") then qceval:do-cancel($crid) else 
() return $result } catch ($e) { 
xdmp:set-response-content-type(fn:string-join(("application/json", 
"charset=utf-8"), "; ")), xdmp:set-response-code(500, $e/error:format-string), 
json:transform-to-json-string(&lt;error&gt;{ $e/error:format-string 
}&lt;/error&gt;, json:config("custom")) } -- Time limit 
exceeded</error:format-string>
2016-08-01 16:17:03.130 Info: App-Services:   
<error:retryable>false</error:retryable>
2016-08-01 16:17:03.130 Info: App-Services:   <error:expr>try { let $_ := 
sec:secure-x-frame() let $_ := sec:secure-request-params("evaler") let $set := 
amped-common:appservices-expire-headers() let $params-map := 
rest:process-request($http-opts) let $action := map:get($params-map, "action") 
let $qid := map:get($params-map, "qid") let $name := map:get($params-map, 
"name") let $active := map:get($params-map, "active") let $focus := 
map:get($params-map, "focus") let $mode := fn:lower-case(map:get($params-map, 
"mode")) let $content-source := map:get($params-map, "content-source") let 
$wsid := map:get($params-map, "wsid") let $sid := map:get($params-map, "sid") 
let $dbid := map:get($params-map, "dbid") let $crid := map:get($params-map, 
"crid") let $query-type := map:get($params-map, "querytype") let $query-text := 
xdmp:get-request-body("text") let $sql-query := "import module namespace 
amped-qconsole = &amp;quot;http://marklogic...."; let $sparql-query := "import 
module namespace amped-qconsole = &amp;quot;http://marklogic...."; let 
$sparql-update-query := "import module namespace amped-qconsole = 
&amp;quot;http://marklogic...."; return if (fn:exists($qid) and 
fn:not(qconsole-model:is-query-found($qid))) then let $msg := fn:concat("Query 
with this ID ", $qid, " does not exist") let $code := 
xdmp:set-response-code(404, $msg) return 
json:transform-to-json-string(&lt;error&gt;{ $msg }&lt;/error&gt;, 
json:config("custom")) else let $query := $query-text let $new-query := if 
(fn:empty($qid) and $wsid) then let $new-query := 
amped-qconsole:qconsole-eval("import module namespace qconsole-model = 
&amp;quot;http://marklogic....";, (fn:QName("","wsid"), $wsid), ()) return 
xdmp:set($qid, $new-query/id) else () let $eval-opts := if ($sid or $dbid) then 
amped-qconsole:qconsole-get-eval-options($sid, $dbid, fn:true()) else () let 
$result := if ($action eq "eval") then if ($query-type eq "xquery") then 
(qceval:do-eval($qid, $query, "", $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else if ($query-type 
eq "sql") then (qceval:do-eval($qid, $query, $sql-query, $eval-opts, 
$query-type), qceval:replica-database-set-response-message($sid, $dbid)) else 
if ($query-type eq "sparql") then (qceval:do-eval($qid, $query, $sparql-query, 
$eval-opts, $query-type), qceval:replica-database-set-response-message($sid, 
$dbid)) else if ($query-type eq "sparql-update") then (qceval:do-eval($qid, 
$query, $sparql-update-query, $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else () else if 
($action eq "profile") then if ($query-type eq "xquery") then 
(qceval:do-profile($qid, $query, "", $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else if ($query-type 
eq "sql") then (qceval:do-profile($qid, $query, $sql-query, $eval-opts, 
$query-type), qceval:replica-database-set-response-message($sid, $dbid)) else 
if ($query-type eq "sparql") then (qceval:do-profile($qid, $query, 
$sparql-query, $eval-opts, $query-type), 
qceval:replica-database-set-response-message($sid, $dbid)) else if ($query-type 
eq "sparql-update") then (qceval:do-profile($qid, $query, $sparql-update-query, 
$eval-opts, $query-type), qceval:replica-database-set-response-message($sid, 
$dbid)) else () else if ($action eq "cancel") then qceval:do-cancel($crid) else 
() return $result } catch ($e) { 
xdmp:set-response-content-type(fn:string-join(("application/json", 
"charset=utf-8"), "; ")), xdmp:set-response-code(500, $e/error:format-string), 
json:transform-to-json-string(&lt;error&gt;{ $e/error:format-string 
}&lt;/error&gt;, json:config("custom")) }</error:expr>
2016-08-01 16:17:03.130 Info: App-Services:   <error:data/>
2016-08-01 16:17:03.130 Info: App-Services:   <error:stack>
2016-08-01 16:17:03.130 Info: App-Services:     <error:frame>
2016-08-01 16:17:03.130 Info: App-Services:       
<error:uri>/qconsole/endpoints/evaler.xqy</error:uri>
2016-08-01 16:17:03.130 Info: App-Services:       <error:line>147</error:line>
2016-08-01 16:17:03.130 Info: App-Services:       <error:column>8</error:column>
2016-08-01 16:17:03.130 Info: App-Services:       <error:variables>
2016-08-01 16:17:03.130 Info: App-Services:     <error:variable>
2016-08-01 16:17:03.130 Info: App-Services:       <error:name 
xmlns="">http-opts</error:name>
2016-08-01 16:17:03.130 Info: App-Services:       <error:value>&lt;rest:request 
xmlns:rest="http://marklogic.com/appservices/rest"&gt;&lt;rest:param name="sid" 
as="unsignedLong"/&gt;&lt;rest:param 
name="dbid...&lt;/rest:request&gt;</error:value>
2016-08-01 16:17:03.130 Info: App-Services:     </error:variable>
2016-08-01 16:17:03.130 Info: App-Services:     <error:variable>
2016-08-01 16:17:03.130 Info: App-Services:       <error:name 
xmlns="">e</error:name>
2016-08-01 16:17:03.130 Info: App-Services:       <error:value>&lt;error:error 
xsi:schemaLocation="http://marklogic.com/xdmp/error error.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:error="http://marklogic.com/xdmp/error"&gt;&lt;error:code&gt;XDMP-EXTIME&lt;/error:code&gt;&lt;error:name/&gt;&lt;error:xquery-v...&lt;/error:error&gt;</error:value>
2016-08-01 16:17:03.130 Info: App-Services:     </error:variable>
2016-08-01 16:17:03.130 Info: App-Services:       </error:variables>
2016-08-01 16:17:03.130 Info: App-Services:       
<error:xquery-version>1.0-ml</error:xquery-version>
2016-08-01 16:17:03.130 Info: App-Services:     </error:frame>
2016-08-01 16:17:03.130 Info: App-Services:   </error:stack>
2016-08-01 16:17:03.130 Info: App-Services: </error:error>
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (2000 Galloping Hill Road, Kenilworth,
New Jersey, USA 07033), and/or its affiliates Direct contact information
for affiliates is available at 
http://www.merck.com/contact/contacts.html) that may be confidential,
proprietary copyrighted and/or legally privileged. It is intended solely
for the use of the individual or entity named on this message. If you are
not the intended recipient, and have received this message in error,
please notify us immediately by reply e-mail and then delete it from 
your system.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to