Search in sources :

Example 1 with KeyValue

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);
}
Also used : KeyValue(com.googlecode.cqengine.index.support.KeyValue) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with KeyValue

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);
}
Also used : KeyValue(com.googlecode.cqengine.index.support.KeyValue) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate)

Aggregations

KeyValue (com.googlecode.cqengine.index.support.KeyValue)2 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)2 Instant (de.invesdwin.util.time.Instant)2 FDate (de.invesdwin.util.time.date.FDate)2 NoSuchElementException (java.util.NoSuchElementException)1