Liking cljdoc? Tell your friends :D

grafter.db.triplestore.query


defquerycljmacro

(defquery var-name sparql-resource args-vector)
(defquery var-name sparql-resource args-vector {:keys [reasoning?] :as opts})

Define a function named var-name for running a sparql query via grafter-2.rdf4j/sparql that is defined in the given sparql-resource file. The symbols used for argument are expected to map directly to variables in the query.

  • :reasoning? true|false whether or not reasoning/inference should be used in the query. DEFAULT: false

e.g. for a SPARQL resource-file containing the query:

SELECT * WHERE { ?s ?p ?o }

The declaration should contain keywords defining the variables you wish to bind. e.g.:

(defquery select-spo "sparql/select-spo.sparql" [:s])

Then to select ?p & ?o on an http://s pass a bindings map of SPARQL var name to its val:

(select-spo {:s (URI. "http://s")})

Special namespaced keyword bindings can be supplied for limits & offsets:

  • :grafter-2.rdf4j.sparql/limits
  • :grafter-2.rdf4j.sparql/offsets

::sp/limits and ::sp/offsets both take a map of of limits that correspond to the overrides in the query. For example with the query:

SELECT * WHERE { SELECT ?s WHERE { ?s ?p ?o . } LIMIT 10 } LIMIT 1

We can override both the inner and outer limits by specifying a value of:

{::sp/limits {10 100 ;; override inner limit with 100 1 1000 ;; override outer limit with 1000 }}

Generated query functions take an optional map of options as their last parameter. Valid options are:

  • :evaluation-method a keyword for the evaluation function (see get-query-fn)

NOTE also that SPARQL variables ?snake_style variable can be referenced with clojure-style-kebab-case names.

Define a function named var-name for running a sparql query via
grafter-2.rdf4j/sparql that is defined in the given sparql-resource file. The
symbols used for argument are expected to map directly to variables in the
query.

- `:reasoning?` `true|false` whether or not reasoning/inference should be used
  in the query. DEFAULT: `false`


e.g. for a SPARQL resource-file containing the query:

SELECT * WHERE { ?s ?p ?o }

The declaration should contain keywords defining the variables you wish to bind.
e.g.:

(defquery select-spo "sparql/select-spo.sparql" [:s])

Then to select ?p & ?o on an <http://s> pass a bindings map of SPARQL var
name to its val:

(select-spo {:s (URI. "http://s")})

Special namespaced keyword bindings can be supplied for limits & offsets:

- :grafter-2.rdf4j.sparql/limits
- :grafter-2.rdf4j.sparql/offsets

::sp/limits and ::sp/offsets both take a map of of limits that correspond to
the overrides in the query.  For example with the query:

SELECT * WHERE {
  SELECT ?s WHERE {
    ?s ?p ?o .
  } LIMIT 10
} LIMIT 1

We can override both the inner and outer limits by specifying a value of:

{::sp/limits {10 100 ;; override inner limit with 100
              1 1000 ;; override outer limit with 1000
}}

Generated query functions take an optional map of options as their last
parameter.  Valid options are:

- `:evaluation-method` a keyword for the evaluation function
  (see get-query-fn)

NOTE also that SPARQL variables ?snake_style variable can be referenced with
clojure-style-kebab-case names.
sourceraw docstring

EvaluationMethodcljprotocol

evaluation-methodclj

(evaluation-method this)
source

generate-bindingsclj

(generate-bindings args-vector)
source

get-query-fncljmultimethod

source

keynameclj

(keyname key)

For namespaced keywords, (name) only returns the keyword part. This function returns the namespace and keyword

For namespaced keywords, (name) only returns the keyword part.
This function returns the namespace and keyword
sourceraw docstring

kmapclj

(kmap f m)

update all keys in a hash-map with function

update all keys in a hash-map with function
sourceraw docstring

rename-bindingclj

(rename-binding binding)

Rename clojure style hyphenated variable-bindings to sparql style underscored_bindings. Exclude ::sp/limits and ::sp/offsets.

Rename clojure style hyphenated variable-bindings to sparql style
underscored_bindings. Exclude ::sp/limits and ::sp/offsets.
sourceraw docstring

wrap-cachingclj

(wrap-caching query-fn)
source

wrap-eager-evaluationclj

(wrap-eager-evaluation query-fn)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close