AGLoadRDF.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.URI;
public class AGLoadRDF {
@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("loadRDF", AGPaths.TRIPLE_STORES);
loadRDFWithTiming(ts, AGPaths.dataSources("rdf-axioms.rdf"));
Cursor cc = ts.getStatements(null, null, null);
AGUtils.showTriples(cc, 20);
URI g = ts.createURI("http://example.org/wilburwine");
loadRDFWithTiming(ts, AGPaths.dataSources("wilburwine.rdf"), g);
cc = ts.getStatements(null, null, null, g);
AGUtils.showTriples(cc, 20);
ts.loadRDF("http://www.w3.org/TR/owl-guide/wine.rdf","source");
cc = ts.getStatements(null, null, null,"<http://www.w3.org/TR/owl-guide/wine.rdf>");
AGUtils.showTriples(cc, 20);
String[] files = {
AGPaths.dataSources("Geonames_v2.0_Lite.rdf"),
AGPaths.dataSources("iswc-aswc-2007-complete.rdf")
};
System.out.println("Loading multiple files ...");
long n = ts.loadRDF(files);
System.out.println("Loaded " + n + " triples.");
ts.closeTripleStore();
ags.disable();
}
public static void loadRDFWithTiming(AllegroGraph ts, String rdfFile) throws AllegroGraphException {
loadRDFWithTiming(ts, rdfFile, "");
}
public static void loadRDFWithTiming(AllegroGraph ts, String rdfFile, Object graph) throws AllegroGraphException {
System.out.println("Loading RDF from " + rdfFile);
long start = System.currentTimeMillis();
long n = ts.loadRDF(rdfFile, graph);
System.out.println("Done loading " + n + " triples in " + AGUtils.elapsedTime(start));
}
}
Up |
Next