List of usage examples for com.google.common.collect MapMaker MapMaker
public MapMaker()
From source file:org.apache.giraph.edge.SimpleEdgeStore.java
@Override protected ConcurrentMap<I, OutEdges<I, E>> getPartitionEdges(int partitionId) { ConcurrentMap<I, OutEdges<I, E>> partitionEdges = (ConcurrentMap<I, OutEdges<I, E>>) transientEdges .get(partitionId);/* www . j av a2 s . c o m*/ if (partitionEdges == null) { ConcurrentMap<I, OutEdges<I, E>> newPartitionEdges = new MapMaker() .concurrencyLevel(configuration.getNettyServerExecutionConcurrency()).makeMap(); partitionEdges = (ConcurrentMap<I, OutEdges<I, E>>) transientEdges.putIfAbsent(partitionId, newPartitionEdges); if (partitionEdges == null) { partitionEdges = newPartitionEdges; } } return partitionEdges; }
From source file:com.torodb.torod.db.metaInf.DefaultDbMetaInformationCache.java
@Inject DefaultDbMetaInformationCache(ExecutorFactory executorFactory, ReservedIdHeuristic subDocTypeIdHeuristic, ReservedIdInfoFactory tableMetaInfoFactory, TorodConfig config) { this.executorFactory = executorFactory; this.createdCollections = new MapMaker().makeMap(); this.creationCollectionPendingJobs = new MapMaker().makeMap(); this.collectionMetaInfoMap = Maps.newHashMap(); this.collectionCreationLock = new ReentrantLock(); this.reserveIdHeuristic = subDocTypeIdHeuristic; this.reservedIdInfoFactory = tableMetaInfoFactory; }
From source file:org.apache.giraph.partition.ByteArrayPartition.java
@Override public void initialize(int partitionId, Progressable progressable) { super.initialize(partitionId, progressable); vertexMap = new MapMaker().concurrencyLevel(getConf().getNettyServerExecutionConcurrency()).makeMap(); representativeVertex = getConf().createVertex(); representativeVertex.initialize(getConf().createVertexId(), getConf().createVertexValue(), getConf().createOutEdges()); useUnsafeSerialization = getConf().useUnsafeSerialization(); }
From source file:io.github.holasylk.collect.guava.GuavaCollectors.java
private static <E> Set<E> newWeakSet() { return Collections.newSetFromMap(new MapMaker().weakKeys().makeMap()); }
From source file:com.notifier.desktop.notification.impl.NotificationManagerImpl.java
@Inject public NotificationManagerImpl(Provider<ApplicationPreferences> preferencesProvider, SwtManager swtManager, OperatingSystemProcessManager processManager, DeviceManager deviceManager, @Tray NotificationBroadcaster trayBroadcaster, @Growl NotificationBroadcaster growlBroadcaster, @Libnotify NotificationBroadcaster libnotifyBroadcaster, @Msn InstantMessagingNotificationBroadcaster msnBroadcaster) { this.broadcasters = ImmutableList.of(trayBroadcaster, growlBroadcaster, libnotifyBroadcaster, msnBroadcaster);//from w w w .java 2 s . c om this.swtManager = swtManager; this.processManager = processManager; this.deviceManager = deviceManager; this.lastNotifications = new MapMaker().initialCapacity(50).expiration(60, SECONDS).makeMap(); ApplicationPreferences prefs = preferencesProvider.get(); this.privateMode = prefs.isPrivateMode(); this.notificationConfigurations = Maps.newEnumMap(Notification.Type.class); for (Notification.Type type : Notification.Type.values()) { NotificationConfiguration config = new NotificationConfiguration(type); config.setEnabled(prefs.isNotificationEnabled(type)); config.setSendToClipboard(prefs.isNotificationClipboard(type)); config.setExecuteCommand(prefs.isNotificationExecuteCommand(type)); config.setCommand(prefs.getNotificationCommand(type)); notificationConfigurations.put(type, config); } }
From source file:org.ttrssreader.utils.AbstractCache.java
/** * Creates a new cache instance./*from w w w. j a v a 2 s .c o m*/ * * @param initialCapacity the initial element size of the cache * @param maxConcurrentThreads how many threads you think may at once access the cache; this need not be an exact * number, but it helps in fragmenting the cache properly */ public AbstractCache(int initialCapacity, int maxConcurrentThreads) { MapMaker mapMaker = new MapMaker(); mapMaker.initialCapacity(initialCapacity); // mapMaker.expiration(expirationInMinutes * 60, TimeUnit.SECONDS); mapMaker.concurrencyLevel(maxConcurrentThreads); mapMaker.softValues(); this.cache = mapMaker.makeMap(); }
From source file:com.torodb.torod.db.backends.metaInf.DefaultDbMetaInformationCache.java
@Inject DefaultDbMetaInformationCache(ExecutorFactory executorFactory, ReservedIdHeuristic subDocTypeIdHeuristic, ReservedIdInfoFactory tableMetaInfoFactory) { this.executorFactory = executorFactory; this.createdCollections = new MapMaker().makeMap(); this.creationCollectionPendingJobs = new MapMaker().makeMap(); this.collectionMetaInfoMap = Maps.newHashMap(); this.collectionCreationLock = new ReentrantLock(); this.reserveIdHeuristic = subDocTypeIdHeuristic; this.reservedIdInfoFactory = tableMetaInfoFactory; }
From source file:com.opengamma.util.map.HashMap2.java
protected ConcurrentMap<K2, V> newSubMap(final K1 key1) { return new MapMaker().makeMap(); }
From source file:com.paxxis.cornerstone.messaging.service.RequestQueueSender.java
public void initialize() { if (this.messageExecutor == null) { //unfortunately it seems we have nothing better for a name (no destination name yet) to //use for the thread pool :( this.messageExecutor = new BlockingThreadPoolExecutor(); this.messageExecutor.setThreadPoolName(this.getClass().getSimpleName()); this.messageExecutor.initialize(); }/*w ww . j av a2 s.com*/ if (this.listenerMap == null) { this.listenerMap = new MapMaker().concurrencyLevel(concurrencyLevel).makeMap(); } }
From source file:com.linagora.scheduling.Monitor.java
private Monitor(ImmutableList<Listener<T>> listeners) { this.listenerNofifier = new ListenersNotifier<>(Monitor.class, listeners); this.tasks = new MapMaker().weakKeys().makeMap(); }