On 18/06/13 18:22, Dick Murray wrote:
I'm looking for dynamic inference based on the select. Given a dataset with
multiple named graphs I would like the ability to wrap specific named
graphs based on some form of filter when the select is processed.
The dataset being queried can not be manipulated during the query.
Whether getGraph is called is evaluator dependent (it's not in TDB which
works on quads).
There is no guarantee a query is executed in a particular order. It
coudl do the GRAPH bit before the dft graph access. Currently, that
unlikely, but there is no guarantee. Oh - and it may happen twice for
rewritten queries (equality optimizations like to generate multiple more
grounded accesses).
Given the dataset D which contains the named graphs G1, G2, G3 I would like
G2 to be returned with RDFS inference if it is queried in a select. I have
achieved this by wrapping the graph as an InfModel and using a
DatasetGraphMap but this requires that the graph be known before the select
is executed. What I'm trying to find (if it exists) is the point during the
select processing when the graph is identified and used? Does this exist in
a TDB Dataset or is it just a set of quads?
Such a point exists (OpExecutor.execute(OpGraph)) but because of
optimization and/or converting to quads.
A TDB datsegraph is a set of triples (dft graph) + a set of quads (named
graphs). Full quad based optimization isn't really done currently but
it will be in future so any internal approach is going to be vulnerable
to changes.
I think you need a 2-phase approach.
Phase-1 is setup - query the data and determine which graphs to add
inference to.
Phase-2 : Build a new datasetgraph and then query that for the real answers.
Maybe that's what you are doing. If you query dgm I'd expect to see the
RDFS inferences but it does not show where you issue the query.
Complete, minimal example?
Andy
Dick.
On 18 June 2013 16:01, Andy Seaborne <[email protected]> wrote:
Dick,
I'm not completely sure what you're trying to do - a complete minimal
example showing how they bits and pieces fit together would be good. It
seems to be querying the dataset without the inference graph. I don't see
where you query the dataset (and which one)
if (graphNode.getURI().equals(**types.getURI())) {
if (graphNode.equals(types.**asNode()) {
On 18/06/13 14:22, Dick Murray wrote:
Hi.
Is it possible to get at the graph i.e. the ?g (specifically the returned
nodes) when the following query is executed?
Yes - getGraph / getNamedModel depending on which level your working at.
SELECT *
WHERE
{ { ?g
<http://www.w3.org/1999/02/22-**rdf-syntax-ns#type<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>
<
http://www.unit4.com/daas/**graph#Graph<http://www.unit4.com/daas/graph#Graph>>
}
GRAPH ?g
{ ?s ?p ?o }
}
When the result is instantiated I want to return the ?g as an RDFS
infmodel. Ideally I want to decide what to return based on the ?g. I've
traced the execSelect() and the ResultSetMem() but drew a blank as to
where
I can get at the ?g's!
ResultSet.next().getResource("**g") ;
or
ResultSet.nextBinding().get(**Var.alloc("g")) ;
The following allows me to wrap the returned graph but this is static i.e.
I need to know the ?g's to generate the dgm to pass to the
QueryExecutionFactory.
dataset.begin(ReadWrite.READ);
DatasetGraphMap dgm = new DatasetGraphMap(dataset.**asDatasetGraph()) {
@Override
public Graph getGraph(Node graphNode) {
Graph g = super.getGraph(graphNode);
if (graphNode.getURI().equals(**types.getURI())) {
g = asRDFS(g);
}
return g;
}
public Graph asRDFS(Graph g) {
return
ModelFactory.createRDFSModel(**ModelFactory.**createModelForGraph(g)).**
getGraph();
}
};
Graph g = dgm.getGraph(types.asNode());
info(g.size());
dataset.end();
For the following triples loaded in the default graph;
@prefix rdf:
<http://www.w3.org/1999/02/22-**rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
.
@prefix rdfs:
<http://www.w3.org/2000/01/**rdf-schema#<http://www.w3.org/2000/01/rdf-schema#>
.
@prefix graph:
<http://www.unit4.com/daas/**graph#<http://www.unit4.com/daas/graph#>
.
@prefix graphs:
<http://www.unit4.com/daas/**graphs/<http://www.unit4.com/daas/graphs/>
.
graph:Graph
rdf:type rdfs:Class.
graphs:g1
rdf:type graph:Graph.
and these loaded in a named graph
<http://www.unit4.com/daas/**graphs/g1<http://www.unit4.com/daas/graphs/g1>
;
@prefix rdf:
<http://www.w3.org/1999/02/22-**rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
.
@prefix rdfs:
<http://www.w3.org/2000/01/**rdf-schema#<http://www.w3.org/2000/01/rdf-schema#>
.
@prefix graph:
<http://www.unit4.com/daas/**graph#<http://www.unit4.com/daas/graph#>
.
@prefix graphs:
<http://www.unit4.com/daas/**graphs/<http://www.unit4.com/daas/graphs/>
.
graphs:g1
rdfs:label "Graph 1".
A select returns;
select * where {{ ?g a
<http://www.unit4.com/daas/**graph#Graph<http://www.unit4.com/daas/graph#Graph>>
}. graph ?g
{?s ?p ?o}}
------------------------------**------------------------------**
------------------------------**------------------------------**
--------------------
| g | s
| p | o |
==============================**==============================**
==============================**==============================**
====================
| <http://www.unit4.com/daas/**graphs/g1<http://www.unit4.com/daas/graphs/g1>>
| <
http://www.unit4.com/daas/**graphs/g1<http://www.unit4.com/daas/graphs/g1>>
| <
http://www.w3.org/2000/01/rdf-**schema#label<http://www.w3.org/2000/01/rdf-schema#label>>
| "Graph 1" |
------------------------------**------------------------------**
------------------------------**------------------------------**
--------------------
What I want is for it to return about 40 more... :-)