Search in sources :

Example 1 with ChronicleMapBuilder

use of net.openhft.chronicle.map.ChronicleMapBuilder in project invesdwin-context-persistence by subes.

the class PersistentChronicleMapFactory method newPersistentMap.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public ConcurrentMap<K, V> newPersistentMap(final IPersistentMapConfig<K, V> config) {
    ChronicleMapBuilder builder = ChronicleMapBuilder.of(Object.class, Object.class);
    builder.name(config.getName()).keyMarshaller(new ChronicleMarshaller<K>(config.newKeySerde())).valueMarshaller(new ChronicleMarshaller<V>(config.newValueSerde())).maxBloatFactor(1_000).entries(100_000);
    builder = configureChronicleMap(config, builder);
    return createChronicleMap(config, builder);
}
Also used : ChronicleMapBuilder(net.openhft.chronicle.map.ChronicleMapBuilder)

Example 2 with ChronicleMapBuilder

use of net.openhft.chronicle.map.ChronicleMapBuilder 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)

Aggregations

ChronicleMapBuilder (net.openhft.chronicle.map.ChronicleMapBuilder)2 APersistentMap (de.invesdwin.context.integration.persistentmap.APersistentMap)1 IPersistentMapConfig (de.invesdwin.context.integration.persistentmap.IPersistentMapConfig)1 PersistentChronicleMapFactory (de.invesdwin.context.persistence.chronicle.PersistentChronicleMapFactory)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