use of com.googlecode.cqengine.index.support.KeyValue in project invesdwin-context-persistence by subes.
the class CqenginePerformanceTest method readOrderedIndex.
private void readOrderedIndex(final NavigableIndex<Long, Content> index) throws InterruptedException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant readsStart = new Instant();
for (int reads = 0; reads < READS; reads++) {
FDate prevValue = null;
int count = 0;
final CloseableIterable<KeyValue<Long, Content>> result = index.getKeysAndValues(QueryFactory.noQueryOptions());
try (CloseableIterator<KeyValue<Long, Content>> it = result.iterator()) {
try {
while (it.hasNext()) {
final FDate value = it.next().getValue().getValue();
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
count++;
}
} catch (final NoSuchElementException e) {
// end reached
}
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("ReadOrderedIndexs", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("ReadOrderedIndexsFinished", readsStart, VALUES * READS, VALUES * READS);
}
use of com.googlecode.cqengine.index.support.KeyValue in project invesdwin-context-persistence by subes.
the class CqenginePerformanceTest method readGetLatestIndex.
private void readGetLatestIndex(final NavigableIndex<Long, Content> index) throws InterruptedException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final List<FDate> values = Lists.toList(newValues());
final Instant readsStart = new Instant();
for (int reads = 0; reads < READS; reads++) {
FDate prevValue = null;
int count = 0;
for (int i = 0; i < values.size(); i++) {
final CloseableIterable<KeyValue<Long, Content>> result = index.getKeysAndValuesDescending(Long.MIN_VALUE, true, values.get(i).millisValue(), true, QueryFactory.noQueryOptions());
try (CloseableIterator<KeyValue<Long, Content>> it = result.iterator()) {
final FDate value = it.next().getValue().getValue();
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
count++;
}
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("GetLatestIndexs", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("GetLatestIndexsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Aggregations