Copy of – Federated Queries with SPARQL

Federated Queries with SPARQL

Bastian Quilitz
( [my first name] [at] quilitz [dot] de )

Last update:  28.06.2006


DARQ is a query engine for federated SPARQL queries. It provides transparent query access to multiple, distributed SPARQL endpoints as if querying a single RDF graph.  DARQ enables the applications to see a single query interface, leaving the details of federation to the query engine. 

DARQ extends Andy Seaborne’s ARQ (included in Jena)by adding a new query planning algorithm and a modified query execution engine. The work on DARQ includes a service description language and a basic query optimization algorithm.

The query engine is in an early stage of development. It cannot deal with all SPARQL queries and is not fully tested (see Limitations and known issues).

  • Source code is available through SVN.
  • License: as per Jena

I’ll be happy receive comments and feedback: mailing list

The Sourceforge project page can be found here.

    • Java 1.5
    • Jena 2.4
    • ARQ 1.4 (not compatible with ARQ shipped with Jena 2.4!)
    • The required jars are included in lib/ .


  1. Download and SVN access
  2. Example: Using DARQ
  3. Service Descriptions
  4. Limitations and known issues

Download and SVN access

DARQ is only available as Java source code from the SVN repository.

svn co darq

Example: Using DARQ

Command line (Linux)
$DARQROOT/bin/darq --query <queryfile> --config <configfile>

<queryfile> file with SPARQL query
<configfile> file with Service Descriptions

There is an detailed example.

Source Code

DARQ provides a single query interface (same as ARQ), leaving the details of federation to the query engine. The example registers the DARQ query engine, executes the query and outputs the results. 

When registering the query engine DARQ requires a configuration file which includes the Service Descriptions.

// register new FedQueryEngineFactory and load configuration from file

// create query
Query query = QueryFactory.create(querystring);

// get query engine
// DarqDataset is a dummy.
QueryExecution qe = QueryExecutionFactory.create(query, new DarqDataset());

// execute query
ResultSet rs = qe.execSelect();

// output results
ResultSetFormatter.out(System.out, rs, query);

Service Descriptions

Service Descriptions specify the capabilities of a SPARQL endpoint. They provide a declarative description of the data available from an endpoint, the definition of limitations on access patterns and statistical information about the available data that is used for query optimization.
Following shows an example for Service Descriptions:

@prefix rdfs: <> .
@prefix rdf: <> .
@prefix xsd: <> .
@prefix sd: <> .

@prefix foaf: <> .

# definition of an endpoint
[] a sd:Service ;
rdfs:label "Foaf Service" ;
rdfs:comment "Service for FOAF data" ;

# the endpoint url
sd:url "http://localhost:2020/ldap" ;

# capabilities of the endpoint
sd:capability [

# the endpoint stores triples with predicate rdf:type
sd:predicate rdf:type ;

# Restriction on the subject/object
# Every legal SPARQL filter expression is allowed.
# only queries for the type
# are allowed

sd:sofilter "REGEX(STR(?object),'')" ;
# could also use ?subject

# statistical information

# number of triples that will be returned by
# a "?s rdf:type ?o" query
sd:triples 18000 ;

# other propeties are:
# Selectivity of a triple pattern, when object/subject is bound
# sd:objectSelectivity (default=1)
# sd:subjectSelectivity (default=1/x,
# where x is the value given by sd:triples)


sd:capability [

# the endpoint stores triples with predicate foaf:name
sd:predicate foaf:name ;

# no filter on subject or object
sd:sofilter "" ;

# statistical information

# there are 18000 triples with predicate foaf:name
sd:triples 18000 ;

# if the object in the triple pattern is bound
# (e.g. ?s foaf:name 'Bastian Quilitz") the result size will be
# reduced by factor 0.02. (on average)
sd:objectSelectivity "0.02"^^xsd:double ;

] ;

sd:capability [
sd:predicate foaf:mbox ;
sd:sofilter "" ;
sd:triples 18000 ;
sd:objectSelectivity 5.5E-5
] ;

# whether the service is definitive or not
# sd:isDefinitive (default=false)
# sd:isDefinitive "true"^^xsd:boolean ;

# limitations on access patterns
# the query for this service must either contain a triple pattern
# with predicate foaf:name and a bound object or
# a pattern with predicate foaf:mbox and a bound object.
# not shown here: sd:subjectBinding -> subject must be bound
sd:requiredBindings [ sd:objectBinding foaf:name ] ;
sd:requiredBindings [ sd:objectBinding foaf:mbox ] ;

# total number of triples in the store
sd:totalTriples 108000;

Limitations and known issues

  • DARQ is in an early stage of development. No extensive testing has been performed.
  • Since DARQ uses predicates to decide where to send triple patterns, no ?s ?p ?o queries are supported – predicates must be bound.
  • Joins using Blank nodes are not supported. If a join operation finds a blank node an exception will be thrown.
  • DESCRIBE is not supported.
  • GRAPH is not supported.
  • Query optimization is not very performant and will not support many endpoint or triples. #endpoints, #triples/endpoint < 7 are a good choice for the moment.

DARQ is hosted by

Bastian Quilitz,  ( [my first name] [at] quilitz [dot] de )

Bastian Quilitz,  ( [my first name] [at] quilitz [dot] de )

About these ads

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s