AGLoadNtriples.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
public class AGLoadNtriples {
@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("loadntriples", AGPaths.TRIPLE_STORES);
String ntripleFile = AGPaths.dataSources("test.nt");
System.out.println("Loading N-Triples " + ntripleFile);
ts.loadNTriples(ntripleFile);
System.out.println("Loaded " + ts.numberOfTriples() + " triples.");
TriplesIterator it = ts.getStatements(null, null, null);
AGUtils.showTriples(it);
URINode g = ts.createURI("http://example.org/kennedy");
long n = ts.loadNTriples(AGPaths.dataSources("kennedy.ntriples"), g);
System.out.println("Loaded " + n + " triples.");
it = ts.getStatements(null, null, ts.createLiteral("Arnold"), g);
AGUtils.showTriples(it);
loadNTriplesWithTiming(ts,"http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt", "source");
it = ts.getStatements("<http://example.org/resource1>", null, null, null);
AGUtils.showTriples(it);
String[] files = {
AGPaths.dataSources("sna.nt"),
AGPaths.dataSources("temporal.nt"),
AGPaths.dataSources("wilburwine.ntriples")
,"http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt"
};
loadNTriplesWithTiming(ts,files,"source");
it = ts.getStatements("<http://example.org/a>", null, null, null);
AGUtils.showTriples(it);
ts.closeTripleStore();
ags.disable();
}
@param
@param
@throws
public static void loadNTriplesWithTiming(AllegroGraph ts, String ntriplesFile) throws AllegroGraphException {
AGLoadNtriples.loadNTriplesWithTiming(ts, ntriplesFile, "");
}
@param
@param
@param
@throws
public static void loadNTriplesWithTiming(AllegroGraph ts, String ntriplesFile, String graph) throws AllegroGraphException {
System.out.println("Loading N-Triples from " + ntriplesFile);
long start = System.currentTimeMillis();
long n = ts.loadNTriples(ntriplesFile,graph,false,null,null);
System.out.println("Loaded " + n + " triples in " + AGUtils.elapsedTime(start));
}
@param
@param
@param
@return
@throws
public static long loadNTriplesWithTiming(AllegroGraph ts, String[] ntriplesFiles, String graph) throws AllegroGraphException {
System.out.println("Loading " + ntriplesFiles.length + " N-Triples files.");
long start = System.currentTimeMillis();
long n = ts.loadNTriples(ntriplesFiles,graph,false,null,null);
System.out.println("Loaded " + n + " triples in " + AGUtils.elapsedTime(start));
return n;
}
}
Up |
Next