AGLoadRDF.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
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"));
TriplesIterator it = ts.getStatements(null, null, null);
AGUtils.showTriples(it, 20);
URINode g = ts.createURI("http://example.org/wilburwine");
loadRDFWithTiming(ts, AGPaths.dataSources("wilburwine.rdf"), g);
it = ts.getStatements(null, null, null, g);
AGUtils.showTriples(it, 20);
ts.loadRDFXML("http://www.w3.org/TR/owl-guide/wine.rdf","source");
it = ts.getStatements(null, null, null,"<http://www.w3.org/TR/owl-guide/wine.rdf>");
AGUtils.showTriples(it, 20);
String[] files = {
AGPaths.dataSources("Geonames_v2.0_Lite.rdf"),
AGPaths.dataSources("iswc-aswc-2007-complete.rdf"),
"http://www.w3.org/TR/2004/REC-owl-guide-20040210/food.rdf"
};
loadRDFWithTiming(ts,files,"source");
it = ts.getStatements("<http://www.geonames.org/ontology#T.ISLT>", null, null, null);
AGUtils.showTriples(it);
ts.closeTripleStore();
ags.disable();
}
@param
@param
@throws
public static void loadRDFWithTiming(AllegroGraph ts, String rdfFile) throws AllegroGraphException {
loadRDFWithTiming(ts, rdfFile, "");
}
@param
@param
@param
@throws
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.loadRDFXML(rdfFile, graph);
System.out.println("Done loading " + n + " triples in " + AGUtils.elapsedTime(start));
}
@param
@param
@param
@return
@throws
public static long loadRDFWithTiming(AllegroGraph ts, String[] rdfFiles, String graph) throws AllegroGraphException {
System.out.println("Loading " + rdfFiles.length + " RDF/XML files.");
long start = System.currentTimeMillis();
long n = ts.loadRDFXML(rdfFiles, graph, null, false, false);
System.out.println("Done loading " + n + " triples in " + AGUtils.elapsedTime(start));
return n;
}
}
Up |
Next