AGSparqlLimitOffset.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGSparqlLimitOffset {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("sparqllimitoffset", AGPaths.TRIPLE_STORES);
AGUtils.loadNTriplesWithTiming(ts,AGPaths.dataSources("kennedy.ntriples"));
ts.indexAllTriples(true);
String query =
"PREFIX ex: <http://example.org/kennedy/> " +
"SELECT ?name " +
"WHERE { ?place ex:name ?name } " +
"ORDER BY ?name " +
"LIMIT 20";
AGUtils.doSparqlSelect(ts, query);
query =
"PREFIX ex: <http://example.org/kennedy/> " +
"SELECT ?name " +
"WHERE { ?place ex:name ?name } " +
"ORDER BY ?name " +
"OFFSET 5 " +
"LIMIT 10";
AGUtils.doSparqlSelect(ts, query);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next