Dear all,
I create a RDF file, I have class HighResolution with definition like :
RasterBased
and (hasSensor some
(Sensor
and (hasResolutionValue some float[> 2.5f , <= 10.0f])))
-----
-----
I write a code in Jena
----
----
package query;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.ModelFactory;
public class query {
public static void main(String[] args) {
OntModel model = ModelFactory.createOntologyModel(
org.mindswap.pellet.jena.PelletReasonerFactory.THE_SPEC, null);
model.read("file:ModelJena.rdf");
model.prepare();
String queryString =
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
"PREFIX test: <
http://www.semanticweb.org/ontologies/2011/4/DataDomain.owl#>"+
"select ?data " +
"where { "+
"}";
System.out.println(queryString);
Query query = QueryFactory.create(queryString);
// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
// Output query results
ResultSetFormatter.out(System.out, results, query);
qe.close();
System.out.println("----------------------");
}
}
----
----
When I query with predefine class like
select ?data
where ?data a test:HighResolution
Jena run 20 minutes and it looks like can not finish. But it can return
correct result quite fast with
select ?data
where ?data test:hasSensor ?sensor.
?sensor test:hasResolutionValue ?resolution.
FILTER ((?resolution > 2.5) && (?resolution <= 10))
It is very strange. Could anybody explant to me why.
Thank in advance.
Binh
--
Trần Thái Bình
GIS and Remote Sensing
[email protected]
[email protected]
Phone: (848) 38247360
mobile:
- Việt Nam -