}
});
}
executor.shutdown();
executor.awaitTermination(5, TimeUnit.MINUTES);
specify(collection.query(new Count(), new Query()), does.equal(totalNumberOfItems));
long time = timer.millisecondsSinceStart();
System.out.println("Insert time for " + totalNumberOfItems + " items was " + time + "ms -> " + (1000 * totalNumberOfItems / time) + " operations per second.");
timer = new StopWatch();
final AtomicInteger count = new AtomicInteger(0);
collection.query(new Query(), new QueryCallback<Map<String, Object>>() {
@Override
public boolean process(Map<String, Object> item) {
if ("bar".equals(item.get("foo"))) {
count.incrementAndGet();
} else {
throw new IllegalStateException("Invalid item: " + item);
}
return true;
}
});
specify(count.get(), does.equal(totalNumberOfItems));
long iterateTime = timer.millisecondsSinceStart();
System.out.println("Iterate " + totalNumberOfItems + " items in " + iterateTime + "ms");
executor = Executors.newFixedThreadPool(50);
timer = new StopWatch();
for (int a = 0; a < 10000; a++) {
executor.submit(new Runnable() {
@Override
public void run() {
collection.query(new Query().setLimit(10), new QueryCallback<Map<String, Object>>() {
@Override
public boolean process(Map<String, Object> item) {
return true;
}
});