public abstract static class Operation.Sparql extends Operation
This operation evaluates a SPARQL query on the KnowledgeStore SPARQL endpoint. All SPARQL query forms are supported:
Stream
of BindingSet
s (call
execTuples()
);Stream
of Statement
s (call
execTriples()
);execBoolean()
).
The operation can be configured, as usual, by specifying a timeout and supplying optional
namespace bindings to be used for parsing the SPARQL expression. In addition,
default
and named
graphs can be specified at the operation level, overriding the corresponding
declarations in the FROM
and FROM NAMED
clauses of the SPARQL query
expression.
Operation.Count, Operation.Create, Operation.Delete, Operation.Download, Operation.Match, Operation.Merge, Operation.Retrieve, Operation.Sparql, Operation.SparqlDelete, Operation.SparqlUpdate, Operation.Update, Operation.Upload
Modifier | Constructor and Description |
---|---|
protected |
Sparql(Map<String,String> namespaces,
String expression,
Object... arguments)
Creates a new
Sparql operation instance (to be used in Session
implementations). |
Modifier and Type | Method and Description |
---|---|
Operation.Sparql |
defaultGraphs(Iterable<org.openrdf.model.URI> defaultGraphs)
Sets the optional default graphs for the query, overriding default graphs specified in
the FROM clause.
|
Operation.Sparql |
defaultGraphs(org.openrdf.model.URI... defaultGraphs)
Sets the optional default graphs for the query, overriding the default graphs specified
in the FROM clause.
|
protected abstract <T> Stream<T> |
doExec(Long timeout,
Class<T> type,
String expression,
Set<org.openrdf.model.URI> defaultGraphs,
Set<org.openrdf.model.URI> namedGraphs)
Implementation method responsible of executing the SPARQL operation.
|
boolean |
execBoolean()
Evaluates the query, returning its boolean result; applicable to ASK queries.
|
Stream<org.openrdf.model.Statement> |
execTriples()
Evaluates the query, returning a
Stream with the resulting Statement s;
applicable to CONSTRUCT and DESCRIBE queries. |
Stream<org.openrdf.query.BindingSet> |
execTuples()
Evaluates the query, returning a
Stream with the resulting BindingSet s;
applicable to SELECT queries. |
Operation.Sparql |
namedGraphs(Iterable<org.openrdf.model.URI> namedGraphs)
Sets the optional named graphs for the query, overriding named graphs specified in the
FROM NAMED clause.
|
Operation.Sparql |
namedGraphs(org.openrdf.model.URI... namedGraphs)
Sets the optional named graphs for the query, overriding named graphs specified in the
FROM NAMED clause.
|
Operation.Sparql |
namespaces(Map<String,String> namespaces)
Sets the optional namespaces for this operation.
|
Operation.Sparql |
timeout(Long timeout)
Sets the optional timeout for this operation in milliseconds.
|
protected Sparql(Map<String,String> namespaces, String expression, Object... arguments) throws ParseException
Sparql
operation instance (to be used in Session
implementations).namespaces
- an immutable map of inherited namespaces, possibly nullexpression
- the SPARQL query expression, not null and possibly containing $$
placeholdersarguments
- the values to assign to $$
placeholdersParseException
- in case the query expression is not validpublic Operation.Sparql timeout(@Nullable Long timeout)
Operation
public Operation.Sparql namespaces(@Nullable Map<String,String> namespaces)
Operation
Session
. Passing null will remove any namespace map
previously set on the operation.namespaces
in class Operation
namespaces
- the namespace map overriding session namespaces; null to resetpublic final Operation.Sparql defaultGraphs(@Nullable org.openrdf.model.URI... defaultGraphs)
defaultGraphs
- a vararg array with the non-null URIs of the default graphs, possibly empty;
pass null to remove any default graph previously setpublic final Operation.Sparql defaultGraphs(@Nullable Iterable<org.openrdf.model.URI> defaultGraphs)
defaultGraphs
- an Iterable
with the non-null URIs of the default graphs, possibly
empty; pass null to remove any default graph previously setpublic final Operation.Sparql namedGraphs(@Nullable org.openrdf.model.URI... namedGraphs)
namedGraphs
- a vararg array with the non-null URIs of the named graphs, possibly empty;
pass null to remove any named graph previously setpublic final Operation.Sparql namedGraphs(@Nullable Iterable<org.openrdf.model.URI> namedGraphs)
namedGraphs
- an Iterable
with the non-null URIs of the named graphs, possibly
empty; pass null to remove any named graph previously setpublic final boolean execBoolean() throws OperationException
OperationException
- on failure (see possible outcome status codes)public final Stream<org.openrdf.model.Statement> execTriples() throws OperationException
Stream
with the resulting Statement
s;
applicable to CONSTRUCT and DESCRIBE queries.Stream
of Statement
sOperationException
- on failure (see possible outcome status codes)public final Stream<org.openrdf.query.BindingSet> execTuples() throws OperationException
Stream
with the resulting BindingSet
s;
applicable to SELECT queries. After access to the returned Stream
, a
List<String>
with output variables can be obtained by querying the
Stream
metadata attribute variables
.Stream
of BindingSet
sOperationException
- on failure (see possible outcome status codes)protected abstract <T> Stream<T> doExec(@Nullable Long timeout, Class<T> type, String expression, @Nullable Set<org.openrdf.model.URI> defaultGraphs, @Nullable Set<org.openrdf.model.URI> namedGraphs) throws OperationException
T
- the type of result elementstimeout
- the optional timeout for the operation; null if there is no timeouttype
- the expected type of elements for the resulting Stream
; either
Statement
, BindingSet
or Boolean
expression
- the SPARQL query expressiondefaultGraphs
- the optional set of default graphs overriding the ones possibly specified in
the FROM
query clause; if null, no override should take placenamedGraphs
- the optional set of named graphs overriding the ones possibly specified in
the FROM NAMED
query clause; if null, no override should take placeStream
with the result of the queryOperationException
- in case of failure (see possible outcome status codes)Copyright © 2015–2016 FBK-irst. All rights reserved.