Search in sources :

Example 31 with MapMaker

use of com.google.common.collect.MapMaker in project DirectMemory by raffaeleguidi.

the class PreliminarBenchmarks method pumpWithOneAllocation.

private void pumpWithOneAllocation(int ops, byte[] payload) {
    ConcurrentMap<String, ByteBuffer> test = new MapMaker().concurrencyLevel(4).maximumSize(ops).expireAfterWrite(10, TimeUnit.MINUTES).makeMap();
    logger.info(Ram.inMb(ops * payload.length) + " in " + ops + " slices to store");
    ByteBuffer bulk = ByteBuffer.allocateDirect(ops * payload.length);
    double started = System.currentTimeMillis();
    for (int i = 0; i < ops; i++) {
        bulk.position(i * payload.length);
        final ByteBuffer buf = bulk.duplicate();
        buf.put(payload);
        test.put("test-" + i, buf);
    }
    double finished = System.currentTimeMillis();
    logger.info("done in " + (finished - started) / 1000 + " seconds");
    for (ByteBuffer buf : test.values()) {
        buf.clear();
    }
}
Also used : MapMaker(com.google.common.collect.MapMaker) ByteBuffer(java.nio.ByteBuffer)

Example 32 with MapMaker

use of com.google.common.collect.MapMaker in project pinpoint by naver.

the class Maps method newWeakConcurrentMap.

public static <K, V> ConcurrentMap<K, V> newWeakConcurrentMap(int initialCapacity) {
    final MapMaker weakMapMaker = createWeakMapMaker();
    weakMapMaker.initialCapacity(initialCapacity);
    return weakMapMaker.makeMap();
}
Also used : MapMaker(com.google.common.collect.MapMaker)

Aggregations

MapMaker (com.google.common.collect.MapMaker)32 EventData (com.alibaba.otter.shared.etl.model.EventData)9 Test (org.junit.Test)9 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)8 RowKey (com.alibaba.otter.node.etl.load.loader.db.DbLoadMerger.RowKey)8 EventColumn (com.alibaba.otter.shared.etl.model.EventColumn)8 Test (org.testng.annotations.Test)8 List (java.util.List)7 DateTime (org.joda.time.DateTime)7 Sequence (io.druid.java.util.common.guava.Sequence)6 TimeseriesQueryQueryToolChest (io.druid.query.timeseries.TimeseriesQueryQueryToolChest)5 TimeseriesResultValue (io.druid.query.timeseries.TimeseriesResultValue)5 Interval (org.joda.time.Interval)5 Function (com.google.common.base.Function)4 Result (io.druid.query.Result)3 ByteBuffer (java.nio.ByteBuffer)3 ConfigException (com.alibaba.otter.shared.common.model.config.ConfigException)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 Node (com.alibaba.otter.shared.common.model.config.node.Node)2 ComputeFunction (com.alibaba.otter.shared.common.utils.cache.RefreshMemoryMirror.ComputeFunction)2