if(file.exists()){
throw new RuntimeException();
}
BenchmarkResults benchmarkResults = new BenchmarkResults();
long startTime = System.currentTimeMillis();
ObjectContainer objectContainer = openOrCreateDatabase(fileName);
if(useIndex){
benchmarkResults._indexEnabled = true;
enableIndex(objectContainer);
}
fillTestData(objectContainer);
benchmarkResults._refillTime = System.currentTimeMillis() - startTime;
//form query for all elements
Query query = objectContainer.query();
query.constrain(BenchmarkObject.class);
query.descend("_val1").constrain(Integer.MIN_VALUE).greater();
query.descend("_val1").constrain(Integer.MAX_VALUE).smaller();
if(sort){
benchmarkResults._sorted = true;
query.descend("_val1").orderAscending();
}
startTime = System.currentTimeMillis();
ObjectSet objectSet = query.execute();
benchmarkResults._queryTime = System.currentTimeMillis() - startTime;
startTime = System.currentTimeMillis();
int total = objectSet.size();
if(total < MAX_OBJECTS){
throw new RuntimeException(""+total);
}
int processed = 0;
// try {
while (objectSet.hasNext()) {
Object next = objectSet.next();
processed++;
}
// } catch(Exception e){
// System.err.println("Processed = "+processed);
// e.printStackTrace();
// throw e;
// }
benchmarkResults._iteration = System.currentTimeMillis() - startTime;
objectContainer.close();
file.delete();
return benchmarkResults;
}