AGSpogiCache.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
public class AGSpogiCache {
@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("sparqlengine", AGPaths.TRIPLE_STORES);
System.out.println("Default SPOGI Cache Size: " + ts.getSPOGICacheSize());
System.out.println("Default SPOGI Cache Enabled: " + ts.isSPOGICacheEnabled());
ts.setSPOGICacheSize(1000000);
ts.setSPOGICacheEnabled(true);
System.out.println("SPOGI Cache Size: " + ts.getSPOGICacheSize());
System.out.println("SPOGI Cache Enabled: " + ts.isSPOGICacheEnabled());
AGLoadNtriples.loadNTriplesWithTiming(ts, AGPaths.dataSources("kennedy.ntriples"));
AGIndexAllTriples.indexAllTriplesWithTiming(ts);
String query =
"PREFIX ex: <http://example.org/kennedy/> " +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"SELECT ?father ?mother ?child ?univ " +
"WHERE {" +
"?father rdf:type ex:person . " +
"?mother rdf:type ex:person . " +
"?mother ex:spouse ?father . " +
"?child rdf:type ex:person . " +
"?father ex:has-child ?child . " +
"?mother ex:has-child ?child . " +
"?father ex:alma-mater ?univ . " +
"?child ex:alma-mater ?univ . " +
"}";
SPARQLQuery sq = new SPARQLQuery();
sq.setTripleStore(ts);
sq.setQuery(query);
sq.setPlanner(SPARQLQuery.PLANNER.IDENTITY);
long start = System.currentTimeMillis();
AGSparqlSelect.doSparqlSelect(sq);
System.out.println("done in " + AGUtils.elapsedTime(start));
start = System.currentTimeMillis();
AGSparqlSelect.doSparqlSelect(sq);
System.out.println("done in " + AGUtils.elapsedTime(start));
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next