Search in sources :

Example 21 with LoopInterruptedCheck

use of de.invesdwin.util.concurrent.loop.LoopInterruptedCheck in project invesdwin-context-persistence by subes.

the class CqenginePerformanceTest method readOrdered.

private void readOrdered(final IndexedCollection<Content> table) throws InterruptedException {
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant readsStart = new Instant();
    for (int reads = 1; reads <= READS; reads++) {
        FDate prevValue = null;
        int count = 0;
        try (ResultSet<Content> result = table.retrieve(QueryFactory.all(Content.class), QueryFactory.queryOptions(QueryFactory.orderBy(QueryFactory.ascending(Content.KEY))))) {
            final Iterator<Content> iterator = result.iterator();
            try {
                while (true) {
                    final FDate value = iterator.next().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("ReadsOrdered", readsStart, VALUES * reads, VALUES * READS);
        }
    }
    printProgress("ReadsOrderedFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : 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 22 with LoopInterruptedCheck

use of de.invesdwin.util.concurrent.loop.LoopInterruptedCheck in project invesdwin-context-persistence by subes.

the class ChronicleMapPerformanceTest method readGet.

private void readGet(final ChronicleMap<Long, Long> table) 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 = 1; reads <= READS; reads++) {
        FDate prevValue = null;
        for (int i = 0; i < values.size(); i++) {
            try {
                final FDate value = new FDate(table.get(values.get(i).millisValue()));
                if (prevValue != null) {
                    Assertions.checkTrue(prevValue.isBefore(value));
                }
                prevValue = value;
            } catch (final NoSuchElementException e) {
                break;
            }
        }
        if (loopCheck.check()) {
            printProgress("Gets", readsStart, VALUES * reads, VALUES * READS);
        }
    }
    printProgress("GetsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : 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 23 with LoopInterruptedCheck

use of de.invesdwin.util.concurrent.loop.LoopInterruptedCheck in project invesdwin-context-persistence by subes.

the class ChronicleMapPerformanceTest method testChronicleMapPerformance.

@Test
public void testChronicleMapPerformance() throws IOException, InterruptedException {
    final File directory = new File(ContextProperties.getCacheDirectory(), ChronicleMapPerformanceTest.class.getSimpleName());
    Files.deleteNative(directory);
    Files.forceMkdir(directory);
    final Instant writesStart = new Instant();
    final ChronicleMapBuilder<Long, Long> mapBuilder = ChronicleMapBuilder.of(Long.class, Long.class).name("testChronicleMapPerformance").constantKeySizeBySample(FDate.MAX_DATE.millisValue()).constantValueSizeBySample(FDate.MAX_DATE.millisValue()).entries(VALUES);
    // final ChronicleMap<Long, Long> map = mapBuilder.create();
    final ChronicleMap<Long, Long> map = mapBuilder.createPersistedTo(new File(directory, "testChronicleMapPerformance"));
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    int i = 0;
    for (final FDate date : newValues()) {
        map.put(date.millisValue(), date.millisValue());
        i++;
        if (i % FLUSH_INTERVAL == 0) {
            if (loopCheck.check()) {
                printProgress("Writes", writesStart, i, VALUES);
            }
        }
    }
    printProgress("WritesFinished", writesStart, VALUES, VALUES);
    readIterator(map);
    readGet(map);
}
Also used : Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) File(java.io.File) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Example 24 with LoopInterruptedCheck

use of de.invesdwin.util.concurrent.loop.LoopInterruptedCheck in project invesdwin-context-persistence by subes.

the class TimeseriesDBPerformanceTest method readGetLatest.

private void readGetLatest(final ATimeSeriesDB<String, FDate> table, final String suffix, final long countReads) throws InterruptedException {
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final List<FDate> values = Lists.toList(newValues());
    final Instant readsStart = new Instant();
    for (long reads = 1; reads <= countReads; reads++) {
        FDate prevValue = null;
        for (int i = 0; i < values.size(); i++) {
            try {
                final FDate value = table.getLatestValue(HASH_KEY, values.get(i));
                if (prevValue != null) {
                    Assertions.checkTrue(prevValue.isBefore(value));
                }
                prevValue = value;
            } catch (final NoSuchElementException e) {
                break;
            }
        }
        if (loopCheck.check()) {
            printProgress("GetLatests" + suffix, readsStart, VALUES * reads, VALUES * countReads);
        }
    }
    printProgress("GetLatests" + suffix + "Finished", readsStart, VALUES * countReads, VALUES * countReads);
}
Also used : 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 25 with LoopInterruptedCheck

use of de.invesdwin.util.concurrent.loop.LoopInterruptedCheck in project invesdwin-context-persistence by subes.

the class HsqldbPerformanceTest method readIterator.

private void readIterator(final Connection conn) throws Exception {
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant readsStart = new Instant();
    final Statement select = conn.createStatement();
    for (int reads = 1; reads <= READS; reads++) {
        FDate prevValue = null;
        int count = 0;
        try (ResultSet results = select.executeQuery("SELECT value FROM abc ORDER BY KEY ASC")) {
            while (results.next()) {
                final FDate value = new FDate(results.getLong(1));
                if (prevValue != null) {
                    Assertions.checkTrue(prevValue.isBefore(value));
                }
                prevValue = value;
                count++;
            }
        }
        Assertions.checkEquals(count, VALUES);
        if (loopCheck.check()) {
            printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
        }
    }
    printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Instant(de.invesdwin.util.time.Instant) ResultSet(java.sql.ResultSet) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate)

Aggregations

LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)65 Instant (de.invesdwin.util.time.Instant)65 FDate (de.invesdwin.util.time.date.FDate)63 NoSuchElementException (java.util.NoSuchElementException)22 Test (org.junit.jupiter.api.Test)19 PreparedStatement (java.sql.PreparedStatement)16 ResultSet (java.sql.ResultSet)15 File (java.io.File)12 Statement (java.sql.Statement)12 RecordFile (com.indeed.lsmtree.recordlog.RecordFile)6 TimedDecimal (de.invesdwin.util.math.decimal.TimedDecimal)6 Connection (java.sql.Connection)5 APersistentMap (de.invesdwin.context.integration.persistentmap.APersistentMap)4 SqlCompiler (io.questdb.griffin.SqlCompiler)4 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)4 SnappyCodec (com.indeed.util.compress.SnappyCodec)3 RecordCursor (io.questdb.cairo.sql.RecordCursor)3 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)3 KeyValue (com.googlecode.cqengine.index.support.KeyValue)2 BasicRecordFile (com.indeed.lsmtree.recordlog.BasicRecordFile)2