Java Code Examples for com.google.common.collect.BiMap#keySet()

The following examples show how to use com.google.common.collect.BiMap#keySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtoRegistry.java    From rejoiner with Apache License 2.0 6 votes vote down vote up
/** 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;
}
 
Example 2
Source File: CircuitImprintLoader.java    From bartworks with MIT License 5 votes vote down vote up
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);
        }
    }
}
 
Example 3
Source File: MiningGraph.java    From SnowGraph with Apache License 2.0 5 votes vote down vote up
/**
 * 判断挖掘出的图是否是给定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;
}
 
Example 4
Source File: ReplaceIdGenerators.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public ObfuscatedNameSuppier(
    RenameStrategy renameStrategy, BiMap<String, String> previousMappings) {
  this.previousMappings = previousMappings.inverse();
  this.generator =
      new NameGenerator(previousMappings.keySet(), "", null);
  this.renameStrategy = renameStrategy;
}
 
Example 5
Source File: Metrics.java    From usergrid with Apache License 2.0 5 votes vote down vote up
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 ) ) );
    }
}
 
Example 6
Source File: ServerTableSizeReader.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 7
Source File: ExportAdmins.java    From usergrid with Apache License 2.0 3 votes vote down vote up
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();
        }