AGIndexAutomatically.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGIndexAutomatically {
@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);
}
long chunkSize = ags.getChunkSize();
System.out.println("Initial index chunk size: " + chunkSize);
ags.setChunkSize(1000);
System.out.println("Setting index chunk size: " + ags.getChunkSize());
AllegroGraph ts = ags.renew("wilburwine", AGPaths.TRIPLE_STORES);
int unindexedThreshold = ts.getUnindexedThreshold();
System.out.println("Current unindexed triples threshold: " + unindexedThreshold);
ts.setUnindexedThreshold(500);
System.out.println("Setting unindexed triples threshold: " + ts.getUnindexedThreshold());
int unmergedThreshold = ts.getUnmergedThreshold();
System.out.println("Current unmerged threshold: " + unmergedThreshold);
ts.setUnmergedThreshold(2);
System.out.println("Setting unmerged threshold: " + ts.getUnmergedThreshold());
String ntripleFile = AGPaths.dataSources("wilburwine.ntriples");
System.out.println("Loading N-Triples " + ntripleFile);
AGUtils.loadNTriplesWithTiming(ts,ntripleFile);
System.out.println("Checking to see if indexing occurred automatically.");
System.out.println("Unmerged Chunks: " + ts.getUnmergedCount());
System.out.println("Unindexed triples: " + ts.getUnindexedTripleCount());
System.out.println("Waiting 5 seconds ...");
try {
Thread.sleep(5000);
} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println("Checking again to see if indexing occurred automatically.");
System.out.println("Unmerged Chunks: " + ts.getUnmergedCount());
System.out.println("Unindexed triples: " + ts.getUnindexedTripleCount());
System.out.println("Returning the server to its prior settings.");
ags.setChunkSize(chunkSize);
ts.setUnindexedThreshold(unindexedThreshold);
ts.setUnmergedThreshold(unmergedThreshold);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next