当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableListMultimap.get方法代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableListMultimap.get方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableListMultimap.get方法的具体用法?Java ImmutableListMultimap.get怎么用?Java ImmutableListMultimap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ImmutableListMultimap的用法示例。


在下文中一共展示了ImmutableListMultimap.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyTypes

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/** 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;
}
 
开发者ID:google,项目名称:rejoiner,代码行数:21,代码来源:ProtoRegistry.java

示例2: writeDiscovery

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
public Result writeDiscovery(
    Iterable<ApiConfig> configs, DiscoveryContext context, SchemaRepository schemaRepository) {
  ImmutableListMultimap<ApiKey, ApiConfig> configsByKey = Multimaps.index(configs,
      new Function<ApiConfig, ApiKey>() {
        @Override public ApiKey apply(ApiConfig config) {
          return config.getApiKey();
        }
      });
  ImmutableMap.Builder<ApiKey, RestDescription> builder = ImmutableMap.builder();
  // "Default" API versions were determined automagically in legacy endpoints.
  // This version only allows to remove an API from default ones by adding
  // defaultVersion = AnnotationBoolean.FALSE to @Api
  ImmutableSet.Builder<ApiKey> preferred = ImmutableSet.builder();
  for (ApiKey apiKey : configsByKey.keySet()) {
    ImmutableList<ApiConfig> apiConfigs = configsByKey.get(apiKey);
    builder.put(apiKey, writeApi(apiKey, apiConfigs, context, schemaRepository));
    // last config takes precedence (same as writeApi)
    if (Iterables.getLast(apiConfigs).getIsDefaultVersion()) {
      preferred.add(apiKey);
    }
  }
  ImmutableMap<ApiKey, RestDescription> discoveryDocs = builder.build();
  return Result.builder()
      .setDiscoveryDocs(discoveryDocs)
      .setDirectory(generateDirectory(discoveryDocs, preferred.build(), context))
      .build();
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:28,代码来源:DiscoveryGenerator.java

示例3: getEditLogManifest

import com.google.common.collect.ImmutableListMultimap; //导入方法依赖的package包/类
/**
 * Return a manifest of what finalized edit logs are available. All available
 * edit logs are returned starting from the transaction id passed. If
 * 'fromTxId' falls in the middle of a log, that log is returned as well.
 * 
 * @param fromTxId Starting transaction id to read the logs.
 * @return RemoteEditLogManifest object.
 */
public synchronized RemoteEditLogManifest getEditLogManifest(long fromTxId) {
  // Collect RemoteEditLogs available from each FileJournalManager
  List<RemoteEditLog> allLogs = Lists.newArrayList();
  for (JournalAndStream j : journals) {
    if (j.getManager() instanceof FileJournalManager) {
      FileJournalManager fjm = (FileJournalManager)j.getManager();
      try {
        allLogs.addAll(fjm.getRemoteEditLogs(fromTxId, false));
      } catch (Throwable t) {
        LOG.warn("Cannot list edit logs in " + fjm, t);
      }
    }
  }
  
  // Group logs by their starting txid
  ImmutableListMultimap<Long, RemoteEditLog> logsByStartTxId =
    Multimaps.index(allLogs, RemoteEditLog.GET_START_TXID);
  long curStartTxId = fromTxId;

  List<RemoteEditLog> logs = Lists.newArrayList();
  while (true) {
    ImmutableList<RemoteEditLog> logGroup = logsByStartTxId.get(curStartTxId);
    if (logGroup.isEmpty()) {
      // we have a gap in logs - for example because we recovered some old
      // storage directory with ancient logs. Clear out any logs we've
      // accumulated so far, and then skip to the next segment of logs
      // after the gap.
      SortedSet<Long> startTxIds = Sets.newTreeSet(logsByStartTxId.keySet());
      startTxIds = startTxIds.tailSet(curStartTxId);
      if (startTxIds.isEmpty()) {
        break;
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Found gap in logs at " + curStartTxId + ": " +
              "not returning previous logs in manifest.");
        }
        logs.clear();
        curStartTxId = startTxIds.first();
        continue;
      }
    }

    // Find the one that extends the farthest forward
    RemoteEditLog bestLog = Collections.max(logGroup);
    logs.add(bestLog);
    // And then start looking from after that point
    curStartTxId = bestLog.getEndTxId() + 1;
  }
  RemoteEditLogManifest ret = new RemoteEditLogManifest(logs);
  
  if (LOG.isDebugEnabled()) {
    LOG.debug("Generated manifest for logs since " + fromTxId + ":"
        + ret);      
  }
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:65,代码来源:JournalSet.java


注:本文中的com.google.common.collect.ImmutableListMultimap.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。