Hi,

This is a common usecase and I have seen it appear over and over ( in
different forms and shapes ).

The objective is to copy all triples in a are remote graph into a
local graph. The remote graph is accessible via SPARQL.

1. Getting the data from the remote end

On the remote SPARQL endpoint, the query to get the contents of the
graph would look something like:
construct {?s ?p ?o} where { graph <urn:graph> { ?s ?p ?o } }
This will return RDF-XML or maybe even turtle ( if we're talking of a
remote Virtuoso instance, then we have some options ).

2. Inserting the data into the local end

Now this is the tricky part. Ideally, this should be totally doable
within Virtuoso.
I managed to create the following procedure ( based on some examples I
found in the docs ).

create procedure UNIVRZ_LOAD_REMOTE_GRAPH (in full_uri varchar, in
graph_uri varchar, in in_resultset integer := 0)
{
  declare REPORT varchar;
  declare dattext varchar;
  declare app_env any;
  app_env := null;
  whenever sqlstate '*' goto err_rep;
  if (not in_resultset)
    result_names (REPORT);
  dattext := cast (XML_URI_GET_AND_CACHE (full_uri) as varchar);
  delete from RDF_QUAD where G = DB.DBA.RDF_MAKE_IID_OF_QNAME (graph_uri);
  DB.DBA.RDF_LOAD_RDFXML_MT (dattext, full_uri, graph_uri);
  return graph_uri;
err_rep:
  result (sprintf ('%s: %s', __SQL_STATE, __SQL_MESSAGE));
  return graph_uri;
}
;

Which I call like so.

UNIVRZ_LOAD_REMOTE_GRAPH(
'http://remoteserver.com/sparql?default-graph-uri=&should-sponge=&query=construct...',
'urn:graph' )

The first parameter is the RESTful URL of a construct query which
should return an RDF-XML document.

So far so good. Of course we could eliminate the first parameter and
compose it from the SPARQL endpoint + the name of the remote graph.
But I didn't even get to that point because I ran into major blocker:

The problem is that the contents of the received file cannot exceed
10MBs in size. This makes it impossible to load large graphs at once!
( in fact, not even 500k triples ).

So, I figured out that the way to do this would be to request TTL or
N3 instead, save it to disk, and then use DB.DBA.TTLP_MT_LOCAL_FILE.

For now I will download the file manually, but I would very much like
to complete and package this procedure. Any tips appreciated.

Thanks,
A


-- 
Aldo Bucchi
skype:aldo.bucchi
http://www.univrz.com/
http://aldobucchi.com/

PRIVILEGED AND CONFIDENTIAL INFORMATION
This message is only for the use of the individual or entity to which it is
addressed and may contain information that is privileged and confidential. If
you are not the intended recipient, please do not distribute or copy this
communication, by e-mail or otherwise. Instead, please notify us immediately by
return e-mail.

Reply via email to