Search in sources :

Example 1 with PersistentTreeMapDBFactory

use of de.invesdwin.context.persistence.mapdb.PersistentTreeMapDBFactory in project invesdwin-context-persistence by subes.

the class TreeMapDBPerformanceTest method testTreeMapDbPerformance.

@Test
public void testTreeMapDbPerformance() throws InterruptedException {
    @SuppressWarnings("resource") final APersistentNavigableMap<FDate, FDate> table = new APersistentNavigableMap<FDate, FDate>("testTreeMapDbPerformance") {

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

        @Override
        public ISerde<FDate> newKeySerde() {
            return FDateSerde.GET;
        }

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

        @Override
        protected IPersistentNavigableMapFactory<FDate, FDate> newFactory() {
            return new PersistentTreeMapDBFactory<>();
        }
    };
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant writesStart = new Instant();
    int i = 0;
    for (final FDate date : newValues()) {
        table.put(date, date);
        i++;
        if (i % FLUSH_INTERVAL == 0) {
            if (loopCheck.check()) {
                printProgress("Writes", writesStart, i, VALUES);
            }
        }
    }
    printProgress("WritesFinished", writesStart, VALUES, VALUES);
    readIterator(table);
    readGet(table);
    readGetLatest(table);
    table.deleteTable();
}
Also used : PersistentTreeMapDBFactory(de.invesdwin.context.persistence.mapdb.PersistentTreeMapDBFactory) Instant(de.invesdwin.util.time.Instant) APersistentNavigableMap(de.invesdwin.context.integration.persistentmap.navigable.APersistentNavigableMap) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Aggregations

APersistentNavigableMap (de.invesdwin.context.integration.persistentmap.navigable.APersistentNavigableMap)1 PersistentTreeMapDBFactory (de.invesdwin.context.persistence.mapdb.PersistentTreeMapDBFactory)1 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)1 Instant (de.invesdwin.util.time.Instant)1 FDate (de.invesdwin.util.time.date.FDate)1 Test (org.junit.jupiter.api.Test)1