AGIndexAllTriples.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGIndexAllTriples {
@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("wilburwine", AGPaths.TRIPLE_STORES);
String ntripleFile = AGPaths.dataSources("wilburwine.ntriples");
System.out.println("Loading N-Triples " + ntripleFile);
AGUtils.loadNTriplesWithTiming(ts,ntripleFile);
ts.registerNamespace("wine", "http://www.w3.org/TR/2003/CR-owl-guide-20030818/wine#");
System.out.println("Triples with Subject: CabernetSauvignonGrape");
long t0 = System.nanoTime();
Cursor cc = ts.getStatements("!wine:CabernetSauvignonGrape",null, null);
AGUtils.showTriples(cc);
long t1 = System.nanoTime();
System.out.println("Query (before indexing) took " + (long)(t1-t0) + " nanoseconds");
ts.indexAllTriples();
System.out.println("Triples with Subject: CabernetSauvignonGrape");
long t2 = System.nanoTime();
cc = ts.getStatements("!wine:CabernetSauvignonGrape",null, null);
AGUtils.showTriples(cc);
long t3 = System.nanoTime();
System.out.println("Query (after indexing) took " + (long)(t3-t2) + " nanoseconds");
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next