Wednesday, January 04, 2006

ARQ 1.2

ARQ 1.2 has been released. One new feature of note is the introduction of property functions where some arbitrary piece of code is used to calculate matches. A use of this is getting the elements in an RDF list which is rather hard in SPARQL otherwise. Property Functions
  • list:member - access the members of an RDF list.
  • rdfs:member - access the members of rdf:Bag, rdf:Seq and rdf:Alt structures
Full Extension documentation

Normally, the unit of matching in ARQ is the basic graph pattern (a sequence of triple patterns). These sets of triple patterns are dispatched to Jena for matching by Jena's graph-level query handler. Each kind of storage provides the appropriate query handler. For example, the database fastpath is a translation of a set of triple patterns into a single SQL query involving joins. There is also a default implementation that works by using plain graph find (a triple with wildcards) so a new storage system does not need to provide it's own query handler until it wants to exploit some feature of the storage. If a magic property is encountered, then it internally treated as a call to be an extension. There is a registry of property to implementing code.

# Find all the members of a list (RDF collection)
PREFIX  list:   <http://www.jena.hpl.hp.com/ARQ/list#>
SELECT ?member
{ ?x :p ?list .
?list list:member ?member .
}
The functionality of list:member is handled by a class in the extension library so this query is treated much like:
# Find all the members of a list (RDF collection)
PREFIX  ext: <java:com.hp.hpl.jena.query.extension.library.>
SELECT ?member
{ ?x :p ?list .
EXT ext:list(?list, ?x)
}
where ext:list is a function that bind its arguments (unlike a FILTER function).

So, this mechanism shows that collection access can be done in SPARQL without resorting to handling told blank nodes. cwm (which is a forward chaining rules engine) and Euler (which is a backward-chaining rules engine) already provide this style of access. Their property is - the subject and object meanings are the other way. ARQ provides list:member to be like rdfs:member. — Andy

0 comments: