Search in sources :

Example 1 with APersistentMap

use of de.invesdwin.context.integration.persistentmap.APersistentMap in project invesdwin-context-persistence by subes.

the class PersistentChronicleMapPerformanceTest method testChronicleMapPerformance.

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

        @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 IPersistentMapFactory<FDate, FDate> newFactory() {
            return new PersistentChronicleMapFactory<FDate, FDate>() {

                @SuppressWarnings("rawtypes")
                @Override
                protected ChronicleMapBuilder configureChronicleMap(final IPersistentMapConfig<FDate, FDate> config, final ChronicleMapBuilder builder) {
                    return builder.averageKeySize(FDate.BYTES).averageValueSize(FDate.BYTES).entries(VALUES);
                }
            };
        }
    };
    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);
    table.deleteTable();
}
Also used : APersistentMap(de.invesdwin.context.integration.persistentmap.APersistentMap) ChronicleMapBuilder(net.openhft.chronicle.map.ChronicleMapBuilder) Instant(de.invesdwin.util.time.Instant) IPersistentMapConfig(de.invesdwin.context.integration.persistentmap.IPersistentMapConfig) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) PersistentChronicleMapFactory(de.invesdwin.context.persistence.chronicle.PersistentChronicleMapFactory) Test(org.junit.jupiter.api.Test)

Example 2 with APersistentMap

use of de.invesdwin.context.integration.persistentmap.APersistentMap in project invesdwin-context-persistence by subes.

the class PersistentEzdbPerformanceTest method testPersistentEzdbPerformance.

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

        @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 IPersistentMapFactory<FDate, FDate> newFactory() {
            return new PersistentEzdbMapFactory<>();
        }
    };
    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);
    table.deleteTable();
}
Also used : APersistentMap(de.invesdwin.context.integration.persistentmap.APersistentMap) PersistentEzdbMapFactory(de.invesdwin.context.persistence.ezdb.PersistentEzdbMapFactory) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Example 3 with APersistentMap

use of de.invesdwin.context.integration.persistentmap.APersistentMap in project invesdwin-context-persistence by subes.

the class MapDBPerformanceTest method testMapDbPerformance.

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

        @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 IPersistentMapFactory<FDate, FDate> newFactory() {
            return new PersistentMapDBFactory<>();
        }
    };
    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);
    table.deleteTable();
}
Also used : APersistentMap(de.invesdwin.context.integration.persistentmap.APersistentMap) Instant(de.invesdwin.util.time.Instant) PersistentMapDBFactory(de.invesdwin.context.persistence.mapdb.PersistentMapDBFactory) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Example 4 with APersistentMap

use of de.invesdwin.context.integration.persistentmap.APersistentMap in project invesdwin-context-persistence by subes.

the class PersistentTkrzwMapPerformanceTest method testTkrzwMapPerformance.

@Test
public void testTkrzwMapPerformance() throws InterruptedException {
    // tkh = HashDBM
    // tkt = TreeDBM
    // tks = SkipDBM (make sure to call synchronize)
    @SuppressWarnings("resource") final APersistentMap<FDate, FDate> table = new APersistentMap<FDate, FDate>("testTkrzwMapPerformance.tkh") {

        @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 IPersistentMapFactory<FDate, FDate> newFactory() {
            return new PersistentTkrzwMapFactory<FDate, FDate>();
        }
    };
    final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
    final Instant writesStart = new Instant();
    int i = 0;
    final TkrzwMap<FDate, FDate> delegate = (TkrzwMap<FDate, FDate>) table.getPreLockedDelegate();
    table.getReadLock().unlock();
    for (final FDate date : newValues()) {
        table.put(date, date);
        i++;
        if (i % FLUSH_INTERVAL == 0) {
            if (loopCheck.check()) {
                printProgress("Writes", writesStart, i, VALUES);
                delegate.getDbm().synchronize(true);
            }
        }
    }
    printProgress("WritesFinished", writesStart, VALUES, VALUES);
    delegate.getDbm().synchronize(true);
    readIterator(table);
    readGet(table);
    table.deleteTable();
}
Also used : APersistentMap(de.invesdwin.context.integration.persistentmap.APersistentMap) Instant(de.invesdwin.util.time.Instant) LoopInterruptedCheck(de.invesdwin.util.concurrent.loop.LoopInterruptedCheck) FDate(de.invesdwin.util.time.date.FDate) Test(org.junit.jupiter.api.Test)

Aggregations

APersistentMap (de.invesdwin.context.integration.persistentmap.APersistentMap)4 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)4 Instant (de.invesdwin.util.time.Instant)4 FDate (de.invesdwin.util.time.date.FDate)4 Test (org.junit.jupiter.api.Test)4 IPersistentMapConfig (de.invesdwin.context.integration.persistentmap.IPersistentMapConfig)1 PersistentChronicleMapFactory (de.invesdwin.context.persistence.chronicle.PersistentChronicleMapFactory)1 PersistentEzdbMapFactory (de.invesdwin.context.persistence.ezdb.PersistentEzdbMapFactory)1 PersistentMapDBFactory (de.invesdwin.context.persistence.mapdb.PersistentMapDBFactory)1 ChronicleMapBuilder (net.openhft.chronicle.map.ChronicleMapBuilder)1