//String baseGraphName = "com.ibm.test.graphNamePrefix.";
long totalExecTime = 0L;
long size = 0;
Dataset dataset = TDBFactory.createDataset(location);
Dataset dataset1 = TDBFactory.createDataset(location);
if ( bracketWithReader )
dataset1.begin(ReadWrite.READ) ;
for (int i = 0; i < TOTAL; i++) {
List<String> lastProcessedUris = new ArrayList<String>();
for (int j = 0; j < 10*i; j++) {
String lastProcessedUri = "http://test.net/xmlns/test/1.0/someUri" + j;
lastProcessedUris.add(lastProcessedUri);
}
//Dataset dataset = TDBFactory.createDataset(location);
//String graphName = baseGraphName + i;
long t = System.currentTimeMillis();
try {
dataset.begin(ReadWrite.WRITE);
Model m = dataset.getDefaultModel();
m.removeAll();
Resource subject = m.createResource(INDEX_INFO_SUBJECT);
Property predicate = m.createProperty(TIMESTAMP_PREDICATE);
m.addLiteral(subject, predicate, System.currentTimeMillis());
predicate = m.createProperty(URI_PREDICATE);
for (String uri : lastProcessedUris) {
m.add(subject, predicate, m.createResource(uri));
}
predicate = m.createProperty(VERSION_PREDICATE);
m.addLiteral(subject, predicate, 1.0);
size += m.size() + 1;
predicate = m.createProperty(INDEX_SIZE_PREDICATE);
m.addLiteral(subject, predicate, size);
dataset.commit();
} catch (Throwable e) {
dataset.abort();
throw new RuntimeException(e);
} finally {
dataset.end();
long writeOperationDuration = System.currentTimeMillis() - t;
totalExecTime += writeOperationDuration;
System.out.println("Write operation " + i + " took " + writeOperationDuration + "ms");
}
}
if ( bracketWithReader )
dataset1.end() ;
System.out.println("All " + TOTAL + " write operations wrote " + size + " triples and took " + totalExecTime + "ms");
}