@Override public V get(K key, final Callable<? extends V> valueLoader) { synchronized (key) { V value = cache.get(key); if (value != null) { return value; } try { value = valueLoader.call(); cache.put(key, value); return value; } catch (Exception e) { throw new ISE(e, "got an exception while loading key [%s]", key); } } }
ImmutableSet.Builder<V> setOfValuesBuilder = ImmutableSet.builder(); for (Map.Entry<K, V> entry : entries) { mapCache.put(entry.getKey(), entry.getValue()); setOfValuesBuilder.add(entry.getValue());
@Override public String put(String key, String value) { return this.hashMap.put(key, value); }
/** * Stores container information for a given id in the Container Map. * * @param id the {@link Id} of the contained element * @param container the {@link ContainerInfo} descriptor containing element's container information to store */ public void storeContainer(Id id, ContainerInfo container) { containersMap.put(id, container); }
/** * Stores the value of a given {@link FeatureKey}. * * @param key the {@link FeatureKey} to set the value of * @param value an {@link Object} representing the value associated to the given {@code key} * * @return ??? */ public Object storeValue(FeatureKey key, Object value) { return features.put(key, value); }
/** * Stores metaclass ({@link EClass}) information for the element with the given {@link Id}. * * @param id the {@link Id} of the element * @param metaclass the {@link ClassInfo} descriptor containing element's metaclass information ({@link EClass}, * meta-model name, and {@code nsURI}) */ public void storeMetaclass(Id id, ClassInfo metaclass) { instanceOfMap.put(id, metaclass); }
/** * Adds item to the cache. * * @param key - An identifiable key for the item added * @param value - The item added */ protected void addToCache(Object key, CacheObject value){ this.cache.put(key, value); }
/** * Adds item to the cache. * * @param key - An identifiable key for the item added * @param value - The item added */ protected void addToCache(Object key, CacheObject value){ this.cache.put(key, value); }
/** * Stores the value of a given {@link MultivaluedFeatureKey}. * <p> * This method is similar to {@link #storeValue(FeatureKey, Object)} but it uses the multi-valued {@link Map} that * stores indices explicitly. * * @param key the {@link MultivaluedFeatureKey} to set the value of * @param value an {@link Object} representing the value associated to the given {@code key} * * @return ??? * * @see DirectWriteMapDbIndicesStore */ public Object storeValueAtIndex(MultivaluedFeatureKey key, Object value) { return multivaluedFeatures.put(key, value); }
public DB put(StorageMaps map, byte[] key, byte[] value){ if(map == StorageMaps.ACCOUNTS){ accountsMap.put(key, value); return accountsDB; }else if(map == StorageMaps.BLOCKS){ blocksMap.put(key,value); return blocksDB; }else if(map == StorageMaps.TRANSACTIONS){ transactionsMap.put(key,value); return transactionsDB; }else if(map == StorageMaps.CONTRACT_CODE){ contractCodeMap.put(key,value); return contractCodeDB; }else if(map == StorageMaps.CONTRACT_STATE){ contractStatesMap.put(key,value); return contractStatesDB; } else return null; }
@Override public <T> void put(String key, T value, long expireTime) { map.put(key,value); timestampMap.put(key,System.currentTimeMillis()); expireTimeMap.put(key,expireTime); }
@Override public void taxonSameAs(String ottId, String nonOttId) { long value = Long.parseLong(ottId); idLookup.put(nonOttId, value); String[] split = nonOttId.split(":"); if (split.length > 1) { prefix.add(split[0] + ":"); } } };
/** * Saves a {@code value} identified by the {@code key} in the {@code database}. * * @param database the database where to save the value * @param key the key of the element to save * @param value the value to save * @param <K> the type of the key * @param <V> the type of the value * * @return an {@link Optional} containing the previous element, or an empty {@link Optional} if there is not any * previous element */ @Nonnull @SuppressWarnings("unchecked") protected <K, V> Optional<V> put(HTreeMap<K, ? super V> database, K key, V value) { return Optional.ofNullable((V) database.put(key, value)); }
private synchronized void updateEmpty(String key) { if (_map.get(key) == null) { _map.put(key, new ArrayList<IMessage>()); } } }
private synchronized void updateEmpty(String key) { if (_map.get(key) == null) { _map.put(key, new ArrayList<IMessage>()); } } }
@Override public void put(Long nodeId, OSMCoordinateSequence coord) { Preconditions.checkNotNull(nodeId, "id is null"); Preconditions.checkNotNull(coord, "coord is null"); Preconditions.checkArgument(1 == coord.size(), "coord list size is not 1"); int[] ordinates = coord.ordinates(); Long key = keyFor(nodeId); Batch e = getOrCreate(key); e.add(nodeId, ordinates); pointMap.put(key, e); }
public synchronized void setProperty(String property, String value) { AssertionUtils.assertNotNull(new IllegalArgumentException("property"), property); AssertionUtils.assertNotNull(new IllegalArgumentException("value"), value); DB db = getDB(false); try { getMap(db).put(property, value); db.commit(); } finally { db.close(); } }
@NotNull private CacheRevision loadCacheRevision(@NotNull ObjectReader reader, @NotNull RevCommit newCommit, int revisionId) throws IOException, SVNException { final ObjectId cacheKey = newCommit.copy(); CacheRevision result = revisionCache.get(cacheKey); if (result == null) { final RevCommit baseCommit = LayoutHelper.loadOriginalCommit(reader, newCommit); final GitFile oldTree = getSubversionTree(reader, newCommit.getParentCount() > 0 ? newCommit.getParent(0) : null, revisionId - 1); final GitFile newTree = getSubversionTree(reader, newCommit, revisionId); final Map<String, CacheChange> fileChange = new TreeMap<>(); for (Map.Entry<String, GitLogPair> entry : ChangeHelper.collectChanges(oldTree, newTree, true).entrySet()) { fileChange.put(entry.getKey(), new CacheChange(entry.getValue())); } result = new CacheRevision( baseCommit, collectRename(oldTree, newTree), fileChange ); revisionCache.put(cacheKey, result); } return result; }
public static FirmwareData getFirmwareDataFromOfflineMap(Integer typeId, Integer versionId) { FirmwareData firmwareData = getFirmwareMap().get(getFirmwareDataOfflineMapName(typeId, versionId)); if (firmwareData == null) { //firmwareData = DaoUtils.getFirmwareDataDao().getByTypeVersion(typeId, versionId); firmwareData = loadFirmwareDataFromDisk(typeId, versionId); if (firmwareData != null) { getFirmwareMap().put(getFirmwareDataOfflineMapName(typeId, versionId), firmwareData); } } return firmwareData; }
public static FirmwareData getFirmwareDataFromOfflineMap(Integer typeId, Integer versionId) { FirmwareData firmwareData = getFirmwareMap().get(getFirmwareDataOfflineMapName(typeId, versionId)); if (firmwareData == null) { //firmwareData = DaoUtils.getFirmwareDataDao().getByTypeVersion(typeId, versionId); firmwareData = loadFirmwareDataFromDisk(typeId, versionId); if (firmwareData != null) { getFirmwareMap().put(getFirmwareDataOfflineMapName(typeId, versionId), firmwareData); } } return firmwareData; }