AGLoadNtriples.java
package com.franz.ag.examples;
import com.franz.ag.*;
import org.openrdf.model.URI;
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("testnt", 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.");
Cursor cc = ts.getStatements(null, null, null);
AGUtils.showTriples(cc);
URI g = ts.createURI("http://example.org/kennedy");
long n = ts.loadNTriples(AGPaths.dataSources("kennedy.ntriples"), g);
System.out.println("Loaded " + n + " triples.");
cc = ts.getStatements(null, null, ts.createLiteral("Arnold"), g);
AGUtils.showTriples(cc);
String[] files = {
AGPaths.dataSources("sna.nt"),
AGPaths.dataSources("temporal.nt"),
AGPaths.dataSources("wilburwine.ntriples")
};
System.out.println("Loading multiple files ...");
n = ts.loadNTriples(files, "source");
System.out.println("Loaded " + n + " triples.");
ts.closeTripleStore();
ags.disable();
}
public static void loadNTriplesWithTiming(AllegroGraph ts, String ntriplesFile) throws AllegroGraphException {
AGLoadNtriples.loadNTriplesWithTiming(ts, ntriplesFile, "");
}
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));
}
}
Up |
Next