Search in sources :

Example 41 with LoopInterruptedCheck

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

the class PersistentEzdbPerformanceTest method readIterator.

private void readIterator(final APersistentMap<FDate, FDate> 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;
        final Iterator<FDate> range = table.values().iterator();
        int count = 0;
        while (true) {
            try {
                final FDate value = range.next();
                // if (prevValue != null) {
                // Assertions.checkTrue(prevValue.isBefore(value));
                // }
                // prevValue = value;
                count++;
            } catch (final NoSuchElementException e) {
                break;
            }
        }
        Assertions.checkEquals(count, VALUES);
        if (loopCheck.check()) {
            printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
        }
    }
    printProgress("ReadsFinished", 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 42 with LoopInterruptedCheck

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

the class BasicRecordFilePerformanceTest method testBasicRecordFilePerformance.

@Test
public void testBasicRecordFilePerformance() throws IOException, InterruptedException {
    final File directory = new File(ContextProperties.getCacheDirectory(), BasicRecordFilePerformanceTest.class.getSimpleName());
    Files.deleteNative(directory);
    Files.forceMkdir(directory);
    final File file = new File(directory, "testBasicRecordFilePerformance");
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant writesStart = new Instant();
    try (BasicRecordFile.Writer<TimedDecimal> writer = new BasicRecordFile.Writer<>(file, IndeedSerializer.valueOf(TimedDecimalSerde.GET))) {
        int i = 0;
        for (final FDate date : newValues()) {
            writer.append(new TimedDecimal(date, date.millisValue()));
            i++;
            if (i % FLUSH_INTERVAL == 0) {
                if (loopCheck.check()) {
                    printProgress("Writes", writesStart, i, VALUES);
                }
            }
        }
        printProgress("WritesFinished", writesStart, VALUES, VALUES);
    }
    readIterator(file);
}
Also used : BasicRecordFile(com.indeed.lsmtree.recordlog.BasicRecordFile) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) BasicRecordFile(com.indeed.lsmtree.recordlog.BasicRecordFile) File(java.io.File) RecordFile(com.indeed.lsmtree.recordlog.RecordFile) TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Example 43 with LoopInterruptedCheck

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

the class RangeTableDBPerformanceTest method readGet.

private void readGet(final ADelegateRangeTable<String, FDate, FDate> 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 = table.get(HASH_KEY, values.get(i));
                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 44 with LoopInterruptedCheck

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

the class HsqldbPerformanceTest method readGet.

private void readGet(final Connection conn) throws Exception {
    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;
        try (PreparedStatement select = conn.prepareStatement("SELECT value FROM abc where key = ? LIMIT 1")) {
            for (int i = 0; i < values.size(); i++) {
                select.setLong(1, values.get(i).millisValue());
                try (ResultSet results = select.executeQuery()) {
                    Assertions.checkTrue(results.next());
                    final FDate value = new FDate(results.getLong(1));
                    if (prevValue != null) {
                        Assertions.checkTrue(prevValue.isBefore(value));
                    }
                    prevValue = value;
                    count++;
                    if (loopCheck.check()) {
                        printProgress("Gets", readsStart, VALUES * reads + count, VALUES * READS);
                    }
                }
            }
        }
        Assertions.checkEquals(count, VALUES);
    }
    printProgress("GetsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : Instant(de.invesdwin.util.time.Instant) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate)

Example 45 with LoopInterruptedCheck

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

the class HsqldbPerformanceTest method readGetLatest.

private void readGetLatest(final Connection conn) throws Exception {
    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;
        try (PreparedStatement select = conn.prepareStatement("SELECT value FROM abc WHERE key <=? ORDER BY KEY DESC LIMIT 1")) {
            for (int i = 0; i < values.size(); i++) {
                select.setLong(1, values.get(i).millisValue());
                try (ResultSet results = select.executeQuery()) {
                    Assertions.checkTrue(results.next());
                    final FDate value = new FDate(results.getLong(1));
                    if (prevValue != null) {
                        Assertions.checkTrue(prevValue.isBefore(value));
                    }
                    prevValue = value;
                    count++;
                    if (loopCheck.check()) {
                        printProgress("GetLatests", readsStart, VALUES * reads + count, VALUES * READS);
                    }
                }
            }
        }
        Assertions.checkEquals(count, VALUES);
    }
    printProgress("GetLatestsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : Instant(de.invesdwin.util.time.Instant) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) 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