Search in sources :

Example 11 with LoopInterruptedCheck

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

the class BasicRecordFilePerformanceTest method readIterator.

private void readIterator(final File file) throws IOException, InterruptedException {
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck();
    final Instant readsStart = new Instant();
    for (int reads = 1; reads <= READS; reads++) {
        FDate prevValue = null;
        int count = 0;
        try (BasicRecordFile<TimedDecimal> reader = new BasicRecordFile<>(file, IndeedSerializer.valueOf(TimedDecimalSerde.GET))) {
            final RecordFile.Reader<TimedDecimal> iterator = reader.reader();
            while (iterator.next()) {
                final FDate value = iterator.get().getTime();
                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 : BasicRecordFile(com.indeed.lsmtree.recordlog.BasicRecordFile) RecordFile(com.indeed.lsmtree.recordlog.RecordFile) BasicRecordFile(com.indeed.lsmtree.recordlog.BasicRecordFile) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) TimedDecimal(de.invesdwin.util.math.decimal.TimedDecimal) FDate(de.invesdwin.util.time.date.FDate)

Example 12 with LoopInterruptedCheck

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

the class LsmTreePerformanceTest method readIterator.

private void readIterator(final Store<FDate, FDate> table) throws InterruptedException, IOException {
    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<Store.Entry<FDate, FDate>> range = table.iterator();
        int count = 0;
        while (true) {
            try {
                final FDate value = range.next().getValue();
                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 13 with LoopInterruptedCheck

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

the class LsmTreePerformanceTest method readGetLatest.

private void readGetLatest(final Store<FDate, FDate> table) throws InterruptedException, IOException {
    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 Store.Entry<FDate, FDate> entry = table.floor(values.get(i));
                final FDate value = entry.getValue();
                if (prevValue != null) {
                    Assertions.checkTrue(prevValue.isBefore(value));
                }
                prevValue = value;
            } catch (final NoSuchElementException e) {
                break;
            }
        }
        if (loopCheck.check()) {
            printProgress("GetLatests", readsStart, VALUES * reads, VALUES * READS);
        }
    }
    printProgress("GetLatestsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Also used : Instant(de.invesdwin.util.time.Instant) Store(com.indeed.lsmtree.core.Store) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) NoSuchElementException(java.util.NoSuchElementException)

Example 14 with LoopInterruptedCheck

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

the class RangeTableDBPerformanceTest method testLevelDbPerformance.

@Test
public void testLevelDbPerformance() throws InterruptedException {
    final ADelegateRangeTable<String, FDate, FDate> table = new ADelegateRangeTable<String, FDate, FDate>("testLevelDbPerformance") {

        @Override
        protected File getBaseDirectory() {
            return ContextProperties.TEMP_DIRECTORY;
        }

        @Override
        protected ISerde<FDate> newValueSerde() {
            return FDateSerde.GET;
        }

        @Override
        protected ISerde<FDate> newRangeKeySerde() {
            return FDateSerde.GET;
        }
    };
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    RangeBatch<String, FDate, FDate> batch = table.newRangeBatch();
    final Instant writesStart = new Instant();
    int i = 0;
    for (final FDate date : newValues()) {
        batch.put(HASH_KEY, date, date);
        i++;
        if (i % FLUSH_INTERVAL == 0) {
            try {
                if (loopCheck.check()) {
                    printProgress("Writes", writesStart, i, VALUES);
                }
            } catch (final InterruptedException e) {
                throw new RuntimeException(e);
            }
            try {
                batch.flush();
                batch.close();
            } catch (final IOException e) {
                throw new RuntimeException(e);
            }
            batch = table.newRangeBatch();
        }
    }
    try {
        batch.flush();
        batch.close();
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
    printProgress("WritesFinished", writesStart, VALUES, VALUES);
    readIterator(table);
    readGet(table);
    readGetLatest(table);
}
Also used : Instant(de.invesdwin.util.time.Instant) IOException(java.io.IOException) ADelegateRangeTable(de.invesdwin.context.persistence.ezdb.table.range.ADelegateRangeTable) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Example 15 with LoopInterruptedCheck

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

the class RangeTableDBPerformanceTest method readGetLatest.

private void readGetLatest(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.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", readsStart, VALUES * reads, VALUES * READS);
        }
    }
    printProgress("GetLatestsFinished", 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)

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