All predicatesShow sourcesparql_runtime.pl -- SPARQL runtime support

See also
- rdfql_runtime.pl merges this module with generic predicates as well as runtime libraries for other query languages.
- These routines are part of the entailment modules. See ../entailment/README.txt
Source sparql_true(+Term)
Generated from FILTER Term, where Term must be converted to a boolean as 'Effective Boolean Value'.
Source eval(+Term, -Result)[private]
 eval(+Type, +Term, -Result) is semidet[private]
Evaluate Term, converting the resulting argument to Type.
Source eval_known_typed_literal(+Type, +Plain, -Typed) is semidet[private]
Map known datatypes to a value that is suitable for comparison using Prolog standard order of terms. Note that the mapped time representations can all be compared.
 numeric_literal_value(+Literal, -Value) is semidet[private]
Convert a SPARQL numeric literal into its value for the purpose of comparison-by-value.
To be done
- Move this into the rdf_db library. There we can achieve better performance and we can do more efficient matching.
Source sparql_op(+ListOfDelcs)[private]
Source expand_op(+In, -Clause) is det[private]
Expand SPARQL operators into a nice clause.
Source op(+Operator, -Result) is semidet[private]
Arguments:
Operator- Term of the format Op(Arg...) where each Arg is embedded in its type.
Result- Result-value, embedded in its type.
Source time_part(+Part, +Type, +String, -Value) is semidet[private]
 seconds_xsd_duration(+Seconds, -XSDDuration)[private]
See also
- http://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqdurfunc.html#wp1183764
To be done
- Implement other direction and move this to XSD or datetime library.
 string_op1(+A1, -R, +Op)[private]
 string_op_string(+A, -R)[private]
 string_int_op_string(+S0, +I, -S)[private]
 string_int_int_op_string(+S0, +I, -S)[private]
 string_op2(+A1, +A2, -R, +Op)[private]
Define operations on strings.
Source iri(+Spec, +Base, -IRI)[private]
Source argument_compatible(+A1, +A2, -Bool, +Op)[private]
Source atom_op(+Op, +Atom, -Result)[private]
Source atom_op(+Op, +Atom, +Arg, -Result)[private]
Source atom_op(+Op, +Atom, +A1, +A2, -Result)[private]
Source combine_types_div(+TypeLeft, +TypeRight, -Type)[private]
Source combine_types(+TypeLeft, +TypeRight, -Type)[private]
Source rdf_equal(+RDFTerm, +RDFTerm, -Boolean)[private]
RDF Term equivalence. Described as lexical equivalence, except where we have the logic to do value equivalence.
Source boolean_value(+Content, -Bool)[private]
Convert the value from literal(xsd:boolean, Content) into either 'true' or 'false'.
Source xsd_cast(+Term, -Type, -Arg)[private]
Deals with xsd:dateTime(?a), casting ?a to the XML Schema type dateTime. Supported types are the numeric types, xsd:boolean and xsd:dateTime.
Source eval_cast(+Type, +Value, -Result)[private]
Cast Value to Type, resulting in a typed literal. Currently casts plain literals to the requested type and numeric values to other numeric values.
Source eval_function(+Term, -Result)[private]
Eval user-defined function. User-defined functions are of the form sparql:function(Term, Result).
Source not(+Bool, -Negated)[private]
Source bound(X)[private]
Does not evaluate args. If the argument is a function it is always bound.
Source str(+RDFTerm, -Atom)[private]
Extract lexical representation from RDFTerm.
Source lang(+RDFTerm, -Lang)[private]
Extract language specification from an RDFTerm
Source datatype(+RDFTerm, -IRI)[private]
Extract type specification from an RDFTerm
Source sparql_and(+A, +B, -Result)[private]
Source sparql_or(+A, +B, -Result)[private]
Source isiri(+IRI)[private]
True if IRI is an IRI. We get the argument un-evaluated.
Source regex(+Haystack, +Needle, +Flags) is semidet[private]
Source compiled_regex(+Compiled, +Text) is semidet[private]
Test using a regex that has been prepared. Compiled is a regex blob created by regex_obj/3.
Source regex_replace(+Input, +Pattern, +Replace, +Flags, -Result)[private]
Source regex(+String, +Pattern, +Flags)[private]
TBD:
  • Avoid XPCE
  • Complete flags
Source compiled_regex(+Compiled, +Text) is semidet[private]
Test using a regex that has been prepared. Compiled takes the following forms:
  • XPCE object
Source effective_boolean_value(+Expr, -Bool)[private]
See SPARQL document, section 11.2.2: Effecitive Boolean Value
Source sparql_eval(+Expr, -Results)
Evaluate a SPARQL expression.
Source sparql_eval_raw(+Expr, -Result)
Same as sparql_eval/2, but return the raw result.
Source is_rdf(+Term)[private]
True if Term is a valid RDF term.
Source sparql_find(?From, ?To, ?F, ?T, :Q) is nondet
Implement *(PropertyPath). We should probably collect translated queries in a dynamic predicate to avoid the copy_term. Also, Q will quite often be simple. In that case we can map to rdf_reachable/3, although one of the problems is that rdf_reachable/3 uses rdf_has/3, and does not deal with graphs.

We should be a bit smarter here and choose between forward, backward, two-sided breath-first, etc. based on which start point is given.

To be done
- Maybe a thing for using tor? Planning most likely more important than the iteration speed.
Source query_graph(+Query, -Graph) is semidet[private]
True when Query is associated with graph. Note that property paths are always executed in a single graph.
Source rdf_current_node(?Graph, -Resource)[private]
True when Resource is a resource in Graph. This means it is either a subject or an object of a triple in Graph.
Source rdf_current_node(-Resource)[private]
Generates all known resources on backtracing. This is there to support {?s :p* ?o}. A highly dubious query.
Source sparql_minus(:QLeft, :QRight)
Realise SPARQL MINUS. This is defined to
  • Take the variables of QLeft
  • Determine the result-set for these variables for both QLeft and QRight
  • Substract those from QLeft that are in QRight
To be done
- : Both the result set and the minus set are in standard order of terms, so we can do ordered subtraction.
Source sparql_group(:Goal)
Same as call. Intended to keep groups together to avoid invalid optimizations.
Source sparql_group(:Goal, +OuterVars, +InnerVars)
Execute a group that contains non-steadfast variables, which asks for delayed unification of the output arguments.
Source sparql_service(+Silent, +URL, +Prefixes, +Bindings, +QText)
Execute a remote SPARQL SERVICE request
Arguments:
Silent- is one of silent or error
URL- is the address of the SPARQL server
Prefixes- is a list Prefix-URL
Bindings- is a list VarName=Var
QText- is a string holding the remote query
Source sparql_reset_bnodes
Reset the database for the BNODE(str) function
Source sparql_simplify(:Goal, -Simple) is det
Simplify goals to the SPARQL runtime functions before they are handed to the general optimizer and runtime evaluation.
Source simplify_true(+Expr, -Goal) is semidet[private]
Simplify a boolean expression resulting from a SPARQL FILTER statement. Ideally, this should be a simple partial evaluation of sparql_true/1.
Source simplify_test(+Expr0, -Expr) is det[private]
Perform analysis on specific tests. Currently optimizes regex tests.
Source simplify_eval(+Expr, +Value, -Goal) is semidet[private]
Source sparql_subquery(+Proj, :Query, +Solutions) is nondet
Execute a SPARQL subquery.
Arguments:
Proj- is a list of variables that are shared with the outer query.
To be done
- Call the optimizer.
- Sub queries must be evaluated before the outer query, so we must move them to the head of the query evaluation. Not doing so causes no harm, but leads to repetitive execution of the subquery.
Source sparql_update(:Updates) is det
Handle SPARQL update requests.
To be done
- Realise authorization rules
Source insert_triple(+Graph, +Triple) is det[private]
Source delete_triple(+Graph, +Triple) is det[private]
Delete matching triples
Source delete_triples(+Graph:atom, +SimpleTriplePattern:compound) is det[private]
Source graph(+Spec, -Graph)[private]
Source clear_db(+Clear)[private]
Note that CLEAR ALL cannot use rdf_reset_db because we are in a transaction.