下面列出了com.google.common.collect.BiMap#keySet ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/** Applies the supplied modifications to the GraphQLTypes. */
private static BiMap<String, GraphQLType> modifyTypes(
BiMap<String, GraphQLType> mapping,
ImmutableListMultimap<String, TypeModification> modifications) {
BiMap<String, GraphQLType> result = HashBiMap.create(mapping.size());
for (String key : mapping.keySet()) {
if (mapping.get(key) instanceof GraphQLObjectType) {
GraphQLObjectType val = (GraphQLObjectType) mapping.get(key);
if (modifications.containsKey(key)) {
for (TypeModification modification : modifications.get(key)) {
val = modification.apply(val);
}
}
result.put(key, val);
} else {
result.put(key, mapping.get(key));
}
}
return result;
}
private static void replaceCircuits(BiMap<ItemList, Short> inversed, GT_Recipe original, ItemStack[] in, int index){
for (ItemList il : inversed.keySet()) {
if (GT_Utility.areStacksEqual(il.get(1), original.mInputs[index])) {
in[index] = BW_Meta_Items.getNEWCIRCUITS().getStack(inversed.get(il), original.mInputs[index].stackSize);
}
}
}
/**
* 判断挖掘出的图是否是给定DDG的一个子图
* @param ddg 给定的DDG
* @param sub 挖掘出的图
* @return 如果是子图,则返回sub在ddg中对应结点的集合,反之,返回null
*/
public static Set<DDGBlock> findSubDDG(DDG ddg, Graph<MiningNode, Integer> sub) {
BiMap<DDGBlock, Node<MiningNode, Integer>> nodeMap = HashBiMap.create();
LispList<Node<MiningNode, Integer>> remain = LispList.copyOf(sub.nodeIterator());
if(findSubDDG(ddg, nodeMap, remain.car(), remain.cdr())) return nodeMap.keySet();
return null;
}
public ObfuscatedNameSuppier(
RenameStrategy renameStrategy, BiMap<String, String> previousMappings) {
this.previousMappings = previousMappings.inverse();
this.generator =
new NameGenerator(previousMappings.keySet(), "", null);
this.renameStrategy = renameStrategy;
}
private void applicationsFor( UUID orgId ) throws Exception {
BiMap<UUID, String> applications = managementService.getApplicationsForOrganization( orgId );
for ( UUID uuid : applications.keySet() ) {
logger.info( "Checking app: {}", applications.get( uuid ) );
orgApps.put( orgId, new ApplicationInfo( uuid, applications.get( uuid ) ) );
collect( MetricQuery.getInstance( uuid, MetricSort.APP_REQ_COUNT ).resolution( CounterResolution.DAY )
.startDate( startDate ).endDate( endDate ).execute( emf.getEntityManager( uuid ) ) );
}
}
public Map<String, List<SegmentSizeInfo>> getSegmentSizeInfoFromServers(BiMap<String, String> serverEndPoints,
String tableNameWithType, int timeoutMs) {
int numServers = serverEndPoints.size();
LOGGER.info("Reading segment sizes from {} servers for table: {} with timeout: {}ms", numServers, tableNameWithType,
timeoutMs);
List<String> serverUrls = new ArrayList<>(numServers);
BiMap<String, String> endpointsToServers = serverEndPoints.inverse();
for (String endpoint : endpointsToServers.keySet()) {
String tableSizeUri = "http://" + endpoint + "/table/" + tableNameWithType + "/size";
serverUrls.add(tableSizeUri);
}
// TODO: use some service other than completion service so that we know which server encounters the error
CompletionService<GetMethod> completionService =
new MultiGetRequest(_executor, _connectionManager).execute(serverUrls, timeoutMs);
Map<String, List<SegmentSizeInfo>> serverToSegmentSizeInfoListMap = new HashMap<>();
for (int i = 0; i < numServers; i++) {
GetMethod getMethod = null;
try {
getMethod = completionService.take().get();
URI uri = getMethod.getURI();
String instance = endpointsToServers.get(uri.getHost() + ":" + uri.getPort());
if (getMethod.getStatusCode() >= 300) {
LOGGER.error("Server: {} returned error: {}", instance, getMethod.getStatusCode());
continue;
}
TableSizeInfo tableSizeInfo =
JsonUtils.inputStreamToObject(getMethod.getResponseBodyAsStream(), TableSizeInfo.class);
serverToSegmentSizeInfoListMap.put(instance, tableSizeInfo.segments);
} catch (Exception e) {
// Ignore individual exceptions because the exception has been logged in MultiGetRequest
// Log the number of failed servers after gathering all responses
} finally {
if (getMethod != null) {
getMethod.releaseConnection();
}
}
}
int numServersResponded = serverToSegmentSizeInfoListMap.size();
if (numServersResponded != numServers) {
LOGGER.warn("Finish reading segment sizes for table: {} with {}/{} servers responded", tableNameWithType,
numServersResponded, numServers);
} else {
LOGGER.info("Finish reading segment sizes for table: {}", tableNameWithType);
}
return serverToSegmentSizeInfoListMap;
}
private void saveOrganizations( JsonGenerator jg, AdminUserWriteTask task ) throws Exception {
final BiMap<UUID, String> orgs = task.orgNamesByUuid;
jg.writeFieldName( "organizations" );
jg.writeStartArray();
for (UUID uuid : orgs.keySet()) {
jg.writeStartObject();
jg.writeFieldName( "uuid" );
jg.writeObject( uuid );
jg.writeFieldName( "name" );
jg.writeObject( orgs.get( uuid ) );
jg.writeEndObject();
synchronized (orgsWritten) {
orgsWritten.add( uuid );
}
}
jg.writeEndArray();
}