本文整理了Java中java.util.concurrent.ConcurrentHashMap.getOrDefault()
方法的一些代码示例,展示了ConcurrentHashMap.getOrDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentHashMap.getOrDefault()
方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentHashMap
类名称:ConcurrentHashMap
方法名:getOrDefault
暂无
代码示例来源:origin: google/guava
/**
* Returns the value associated with {@code key}, or zero if there is no value associated with
* {@code key}.
*/
public long get(K key) {
return map.getOrDefault(key, 0L);
}
代码示例来源:origin: prestodb/presto
/**
* Returns the value associated with {@code key}, or zero if there is no value associated with
* {@code key}.
*/
public long get(K key) {
return map.getOrDefault(key, 0L);
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the value associated with {@code key}, or zero if there is no value associated with
* {@code key}.
*/
public long get(K key) {
return map.getOrDefault(key, 0L);
}
代码示例来源:origin: wildfly/wildfly
public V getOrDefault(final Object key, final V defaultValue) {
return backingMap.getOrDefault(key, defaultValue);
}
代码示例来源:origin: apache/incubator-druid
public static ImmutableSet<DerivativeDataSource> getDerivatives(String datasource)
{
return ImmutableSet.copyOf(derivativesRef.get().getOrDefault(datasource, new TreeSet<>()));
}
代码示例来源:origin: uber-common/jvm-profiler
public String getTopic(String profilerName) {
String topic = profilerTopics.getOrDefault(profilerName, null);
if (topic == null || topic.isEmpty()) {
topic = topicPrefix == null ? "" : topicPrefix;
topic += profilerName;
}
return topic;
}
代码示例来源:origin: wildfly/wildfly
public void removeNode(final String clusterName, final String nodeName) {
clusterNodes.getOrDefault(clusterName, Collections.emptySet()).remove(nodeName);
}
代码示例来源:origin: apache/hbase
/**
* Updates the internal table permissions cache for specified table.
* @param table updated table name
* @param tablePerms new table permissions
*/
private void updateTableCache(TableName table, ListMultimap<String, Permission> tablePerms) {
PermissionCache<TablePermission> cacheToUpdate =
tableCache.getOrDefault(table, new PermissionCache<>());
clearCache(cacheToUpdate);
updateCache(tablePerms, cacheToUpdate);
tableCache.put(table, cacheToUpdate);
mtime.incrementAndGet();
}
代码示例来源:origin: apache/hbase
/**
* Updates the internal namespace permissions cache for specified namespace.
* @param namespace updated namespace
* @param nsPerms new namespace permissions
*/
private void updateNamespaceCache(String namespace,
ListMultimap<String, Permission> nsPerms) {
PermissionCache<NamespacePermission> cacheToUpdate =
namespaceCache.getOrDefault(namespace, new PermissionCache<>());
clearCache(cacheToUpdate);
updateCache(nsPerms, cacheToUpdate);
namespaceCache.put(namespace, cacheToUpdate);
mtime.incrementAndGet();
}
代码示例来源:origin: apache/incubator-druid
pendingCompletionTaskGroups.getOrDefault(groupId, new CopyOnWriteArrayList<>()).size() > 0
&& earliestConsistentSequenceId.compareAndSet(-1, taskCheckpoints.firstKey()))) {
final SortedMap<Integer, Map<PartitionIdType, SequenceOffsetType>> latestCheckpoints = new TreeMap<>(
&& pendingCompletionTaskGroups.getOrDefault(groupId, new CopyOnWriteArrayList<>()).size() == 0)) {
代码示例来源:origin: orbit/orbit
&& actorSupported_no != n.canActivate.getOrDefault(interfaceClassName, actorSupported_yes)
&& (n.placementGroupPending.get() || currentTargetPlacementGroups.contains(n.placementGroup)))
.collect(Collectors.toList());
.filter(n -> actorSupported_no != n.canActivate.getOrDefault(interfaceClassName, actorSupported_no)
&& n.placementGroup != null
&& targetPlacementGroups.contains(n.placementGroup))
代码示例来源:origin: apache/ignite
res.centroidStat.put(centroidIdx, centroidStat);
} else {
int cnt = centroidStat.getOrDefault(lb, 0);
centroidStat.put(lb, cnt + 1);
代码示例来源:origin: apache/hbase
/**
* Check if user has given action privilige in table:family scope.
* This method is for backward compatibility.
* @param user user name
* @param table table name
* @param family family names
* @param action one of action in [Read, Write, Create, Exec, Admin]
* @return true if user has, false otherwise
*/
public boolean authorizeUserFamily(User user, TableName table,
byte[] family, Permission.Action action) {
PermissionCache<TablePermission> tblPermissions = tableCache.getOrDefault(table,
TBL_NO_PERMISSION);
if (authorizeFamily(tblPermissions.get(user.getShortName()), table, family, action)) {
return true;
}
for (String group : user.getGroupNames()) {
if (authorizeFamily(tblPermissions.get(AuthUtil.toGroupEntry(group)),
table, family, action)) {
return true;
}
}
return false;
}
代码示例来源:origin: apache/hbase
/**
* Check if user has given action privilige in namespace scope.
* @param user user name
* @param namespace namespace
* @param action one of action in [Read, Write, Create, Exec, Admin]
* @return true if user has, false otherwise
*/
public boolean authorizeUserNamespace(User user, String namespace, Permission.Action action) {
if (user == null) {
return false;
}
if (authorizeUserGlobal(user, action)) {
return true;
}
PermissionCache<NamespacePermission> nsPermissions = namespaceCache.getOrDefault(namespace,
NS_NO_PERMISSION);
if (authorizeNamespace(nsPermissions.get(user.getShortName()), namespace, action)) {
return true;
}
for (String group : user.getGroupNames()) {
if (authorizeNamespace(nsPermissions.get(AuthUtil.toGroupEntry(group)), namespace, action)) {
return true;
}
}
return false;
}
代码示例来源:origin: apache/hbase
return true;
PermissionCache<TablePermission> tblPermissions = tableCache.getOrDefault(table,
TBL_NO_PERMISSION);
if (authorizeTable(tblPermissions.get(user.getShortName()), table, family, qualifier, action)) {
代码示例来源:origin: apache/hbase
/**
* Checks if the user has access to the full table or at least a family/qualifier
* for the specified action.
* @param user user name
* @param table table name
* @param action action in one of [Read, Write, Create, Exec, Admin]
* @return true if the user has access to the table, false otherwise
*/
public boolean accessUserTable(User user, TableName table, Permission.Action action) {
if (user == null) {
return false;
}
if (table == null) {
table = AccessControlLists.ACL_TABLE_NAME;
}
if (authorizeUserNamespace(user, table.getNamespaceAsString(), action)) {
return true;
}
PermissionCache<TablePermission> tblPermissions = tableCache.getOrDefault(table,
TBL_NO_PERMISSION);
if (hasAccessTable(tblPermissions.get(user.getShortName()), action)) {
return true;
}
for (String group : user.getGroupNames()) {
if (hasAccessTable(tblPermissions.get(AuthUtil.toGroupEntry(group)), action)) {
return true;
}
}
return false;
}
代码示例来源:origin: Netflix/spectator
@Override public String apply(String s) {
if (remaining.get() <= 0) {
return values.getOrDefault(s, OTHERS);
} else {
String v = values.get(s);
if (v == null) {
add(s);
v = values.getOrDefault(s, OTHERS);
}
return v;
}
}
代码示例来源:origin: apache/samza
private List<IncomingMessageEnvelope> poll(SystemStreamPartition ssp, String offset) {
int startingOffset = Integer.parseInt(offset);
List<IncomingMessageEnvelope> messageEnvelopesForSSP = bufferedMessages.getOrDefault(ssp, new LinkedList<>());
if (startingOffset >= messageEnvelopesForSSP.size()) {
return new ArrayList<>();
}
return messageEnvelopesForSSP.subList(startingOffset, messageEnvelopesForSSP.size());
}
}
代码示例来源:origin: pravega/pravega
@SneakyThrows(StreamSegmentNotExistsException.class)
private TransactionalEventStreamWriter<byte[]> getTransactionalWriter(String streamName, int routingKey) {
List<TransactionalEventStreamWriter<byte[]>> writers = this.transactionalWriters.getOrDefault(streamName, null);
if (writers == null) {
throw new StreamSegmentNotExistsException(streamName);
}
return writers.get(routingKey % writers.size());
}
代码示例来源:origin: rubenlagus/TelegramBotsExample
private void handleIncomingMessage(Message message) throws InvalidObjectException {
int state = userState.getOrDefault(message.getFrom().getId(), 0);
switch(state) {
case WAITINGCHANNEL:
onWaitingChannelMessage(message);
break;
default:
sendHelpMessage(message.getChatId(), message.getMessageId(), null);
userState.put(message.getFrom().getId(), WAITINGCHANNEL);
break;
}
}
内容来源于网络,如有侵权,请联系作者删除!