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


Java Multimaps.index方法代码示例

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


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

示例1: runImpactAnalysis

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private static Multimap<String, SecurityIndex> runImpactAnalysis(Network network, Set<String> contingencyIds,
                                                                 ComputationManager computationManager, SimulatorFactory simulatorFactory,
                                                                 ContingenciesProvider contingenciesProvider,
                                                                 PrintStream out) throws Exception {
    Stabilization stabilization = simulatorFactory.createStabilization(network, computationManager, 0);
    ImpactAnalysis impactAnalysis = simulatorFactory.createImpactAnalysis(network, computationManager, 0, contingenciesProvider);
    Map<String, Object> initContext = new HashMap<>();
    SimulationParameters simulationParameters = SimulationParameters.load();
    stabilization.init(simulationParameters, initContext);
    impactAnalysis.init(simulationParameters, initContext);
    out.println("running stabilization simulation...");
    StabilizationResult sr = stabilization.run();
    out.println("stabilization status: " + sr.getStatus());
    out.println("stabilization metrics: " + sr.getMetrics());
    if (sr.getStatus() == StabilizationStatus.COMPLETED) {
        out.println("running impact analysis...");
        ImpactAnalysisResult iar = impactAnalysis.run(sr.getState(), contingencyIds);
        out.println("impact analysis metrics: " + iar.getMetrics());

        return Multimaps.index(iar.getSecurityIndexes(), securityIndex -> securityIndex.getId().getContingencyId());

    }
    return null;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:25,代码来源:ImpactAnalysisTool.java

示例2: linkResponses

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private ResponseLinking linkResponses(final Symbol docId,
    final Iterable<Response> responses) {
  final Predicate<Response> HasRelevantRealis =
      compose(in(realisesWhichMustBeAligned), ResponseFunctions.realis());
  final ImmutableSet<Response> systemResponsesAlignedRealis =
      FluentIterable.from(responses).filter(HasRelevantRealis).toSet();

  final Multimap<Symbol, Response> responsesByEventType =
      Multimaps.index(systemResponsesAlignedRealis, ResponseFunctions.type());

  final ImmutableSet.Builder<ResponseSet> ret = ImmutableSet.builder();

  for (final Collection<Response> responseSet : responsesByEventType.asMap().values()) {
    ret.add(ResponseSet.from(responseSet));
  }

  return ResponseLinking.builder().docID(docId).addAllResponseSets(ret.build()).build();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:19,代码来源:SameEventTypeLinker.java

示例3: inferThriftFieldIds

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Assigns all fields an id if possible.  Fields are grouped by name and for each group, if there
 * is a single id, all fields in the group are assigned this id.  If the group has multiple ids,
 * an error is reported.
 */
protected final Set<String> inferThriftFieldIds()
{
    Set<String> fieldsWithConflictingIds = new HashSet<>();

    // group fields by explicit name or by name extracted from field, method or property
    Multimap<String, FieldMetadata> fieldsByExplicitOrExtractedName = Multimaps.index(fields, FieldMetadata::getOrExtractThriftFieldName);
    inferThriftFieldIds(fieldsByExplicitOrExtractedName, fieldsWithConflictingIds);

    // group fields by name extracted from field, method or property
    // this allows thrift name to be set explicitly without having to duplicate the name on getters and setters
    // todo should this be the only way this works?
    Multimap<String, FieldMetadata> fieldsByExtractedName = Multimaps.index(fields, FieldMetadata::extractName);
    inferThriftFieldIds(fieldsByExtractedName, fieldsWithConflictingIds);

    return fieldsWithConflictingIds;
}
 
开发者ID:airlift,项目名称:drift,代码行数:22,代码来源:AbstractThriftMetadataBuilder.java

示例4: getRoleSummary

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Override
public Response getRoleSummary() {
  Multimap<String, IJobKey> jobsByRole = storage.read(
      storeProvider ->
          Multimaps.index(storeProvider.getTaskStore().getJobKeys(), IJobKey::getRole));

  Multimap<String, IJobKey> cronJobsByRole = Multimaps.index(
      Iterables.transform(Storage.Util.fetchCronJobs(storage), IJobConfiguration::getKey),
      IJobKey::getRole);

  Set<RoleSummary> summaries = FluentIterable.from(
      Sets.union(jobsByRole.keySet(), cronJobsByRole.keySet()))
      .transform(role -> new RoleSummary(
          role,
          jobsByRole.get(role).size(),
          cronJobsByRole.get(role).size()))
      .toSet();

  return ok(Result.roleSummaryResult(new RoleSummaryResult(summaries)));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:ReadOnlySchedulerImpl.java

示例5: enrichStructuralVariants

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@NotNull
private static List<EnrichedStructuralVariant> enrichStructuralVariants(@NotNull List<StructuralVariant> variants,
        @NotNull DatabaseAccess dbAccess, @NotNull String tumorSample) {
    final PurityContext purityContext = dbAccess.readPurityContext(tumorSample);

    if (purityContext == null) {
        LOGGER.warn("Unable to retrieve purple data. Enrichment may be incomplete.");
    }

    final PurityAdjuster purityAdjuster = purityContext == null
            ? new PurityAdjuster(Gender.FEMALE, 1, 1)
            : new PurityAdjuster(purityContext.gender(), purityContext.bestFit().purity(), purityContext.bestFit().normFactor());

    final List<PurpleCopyNumber> copyNumberList = dbAccess.readCopynumbers(tumorSample);
    final Multimap<String, PurpleCopyNumber> copyNumbers = Multimaps.index(copyNumberList, PurpleCopyNumber::chromosome);
    return EnrichedStructuralVariantFactory.enrich(variants, purityAdjuster, copyNumbers);
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:18,代码来源:LoadStructuralVariants.java

示例6: writeConfig

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Override
public Map<ApiKey, String> writeConfig(Iterable<? extends ApiConfig> configs)
    throws ApiConfigException {
  Multimap<ApiKey, ? extends ApiConfig> apisByKey = Multimaps.index(configs,
      new Function<ApiConfig, ApiKey>() {
        @Override public ApiKey apply(ApiConfig config) {
          return config.getApiKey();
        }
      });

  // This *must* retain the order of apisByKey so the lily_java_api BUILD rule has predictable
  // output order.
  Map<ApiKey, String> results = Maps.newLinkedHashMap();
  for (ApiKey apiKey : apisByKey.keySet()) {
    Collection<? extends ApiConfig> apiConfigs = apisByKey.get(apiKey);
    validator.validate(apiConfigs);
    results.put(apiKey, generateForApi(apiConfigs));
  }
  return results;
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:21,代码来源:JsonConfigWriter.java

示例7: getChangesetsWithFileDetails

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Override
public List<Changeset> getChangesetsWithFileDetails(List<Changeset> changesets)
{
    ImmutableList.Builder<Changeset> detailedChangesets = ImmutableList.builder();

    // group by repo so we only have to load each repo one time inside the loop
    ListMultimap<Integer, Changeset> changesetsByRepo = Multimaps.index(changesets, Changesets.TO_REPOSITORY_ID);
    for (Map.Entry<Integer, Collection<Changeset>> repoChangesets : changesetsByRepo.asMap().entrySet())
    {
        final Repository repository = repositoryDao.get(repoChangesets.getKey());
        final DvcsCommunicator communicator = dvcsCommunicatorProvider.getCommunicator(repository.getDvcsType());
        processRepository(repository, repoChangesets.getValue(), communicator, detailedChangesets);
    }

    return detailedChangesets.build();
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:17,代码来源:ChangesetServiceImpl.java

示例8: testGroupBy

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Test
public void testGroupBy(){
	List<UserEntity> all = LangUtils.newArrayList();
	List<UserEntity> aa = createUserList("aa", 3);
	List<UserEntity> bb = createUserList("bb", 1);
	List<UserEntity> cc = createUserList("cc", 2);
	all.addAll(aa);
	all.addAll(bb);
	all.addAll(cc);
	
	ImmutableListMultimap<String, UserEntity> groups = Multimaps.index(all, new Function<UserEntity, String>() {

		@Override
		public String apply(UserEntity input) {
			return input.getUserName();
		}
		
	});
	
	System.out.println("groups:" + groups);
	Assert.assertEquals(3, groups.get("aa").size());
	Assert.assertEquals(1, groups.get("bb").size());
	Assert.assertEquals(2, groups.get("cc").size());
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:25,代码来源:GuavaTest.java

示例9: createSummary

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private ImmutableListMultimap<String, CollectorNotificationJson> createSummary(NotificationContent item,
		StringBuilder content) {
	Function<CollectorNotificationJson, String> f = new Function<CollectorNotificationJson, String>() {

		@Override
		public String apply(CollectorNotificationJson notification) {
			return notification.node_alias();
		}
	};
	ImmutableListMultimap<String, CollectorNotificationJson> byNode = Multimaps.index(item.notifications(), f);
	if (byNode.values().size() < 2) {
		log.debug("will not append summary");
		return byNode;
	}
	content.append("Summary:\n");
	for (String n : byNode.keySet()) {
		content.append(n + " -> "
				+ StringUtils.trimStringToMaxLength(Collections2.transform(byNode.get(n), new NotificationToHeaderFunction()).toString(), 250) + " \n");
	}
	content.append("========================================================================\n");

	return byNode;
}
 
开发者ID:codeine-cd,项目名称:codeine,代码行数:24,代码来源:AggregateMailPrepare.java

示例10: align

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Converts a {@link ResponseLinking} to an {@link EventArgumentLinking} using a {@link
 * CorefAnnotation} from an {@link com.bbn.kbp.events2014.AnswerKey} to canonicalize the
 * responses.  If the canonicalization is inconsistent with the response linking, an {@link
 * java.lang.IllegalArgumentException} will be thrown.
 */
public EventArgumentLinking align(ResponseLinking responseLinking,
    AnswerKey answerKey)  {
  checkArgument(answerKey.docId() == responseLinking.docID());

  // assertLinkingSubsetOfAnswerKey(responseLinking, answerKey);
  // the above assertion was too strong - the system response linking could
  // validly include responses which were not included in the answerKey because
  // there was a higher scoring system response in the same equivalence class

  final ImmutableMultimap<TypeRoleFillerRealis, Response> canonicalToResponses =
      Multimaps.index(responseLinking.allResponses(),
          TypeRoleFillerRealis.extractFromSystemResponse(
              answerKey.corefAnnotation().strictCASNormalizerFunction()));

  final Multimap<Response, TypeRoleFillerRealis> responsesToCanonical =
      canonicalToResponses.inverse();

  final ImmutableSet.Builder<TypeRoleFillerRealisSet> coreffedArgs = ImmutableSet.builder();
  for (final ResponseSet responseSet : responseLinking.responseSets()) {
    coreffedArgs.add(TypeRoleFillerRealisSet.from(
        canonicalizeResponseSet(responseSet.asSet(),
            canonicalToResponses, responsesToCanonical)));
  }
  final ImmutableSet<TypeRoleFillerRealis> incompleteResponses = canonicalizeResponseSet(
      responseLinking.incompleteResponses(), canonicalToResponses, responsesToCanonical);

  return EventArgumentLinking.builder().docID(responseLinking.docID())
      .eventFrames(coreffedArgs.build()).incomplete(incompleteResponses).build();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:36,代码来源:ExactMatchEventArgumentLinkingAligner.java

示例11: alignToResponseLinking

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Override
public ResponseLinking alignToResponseLinking(EventArgumentLinking eventArgumentLinking,
    AnswerKey answerKey) {
  // For every Response in answerKey, answerKey.corefAnnotation().strictCASNormalizerFunction() will try to find
  // a canonical coreferent for the Response's CAS (KBPString), by checking CorefAnnotation.CASesToIDs
  // If the KBPString does not exist in CASesToIDs, then an Exception will be thrown
  final ImmutableMultimap<TypeRoleFillerRealis, Response> canonicalToResponses =
      Multimaps.index(answerKey.allResponses(),
          TypeRoleFillerRealis.extractFromSystemResponse(
              answerKey.corefAnnotation().strictCASNormalizerFunction()));

  final ImmutableSet.Builder<Response> incompletes = ImmutableSet.builder();
  for (final TypeRoleFillerRealis incompleteEquivClass : eventArgumentLinking.incomplete()) {
    incompletes.addAll(canonicalToResponses.get(incompleteEquivClass));
  }

  final ImmutableSet.Builder<ResponseSet> responseSets = ImmutableSet.builder();
  for (final TypeRoleFillerRealisSet equivClassSet : eventArgumentLinking.eventFrames()) {
    final ImmutableSet.Builder<Response> setBuilder = ImmutableSet.builder();
    for (final TypeRoleFillerRealis trfr : equivClassSet.asSet()) {
      setBuilder.addAll(canonicalToResponses.get(trfr));
    }
    responseSets.add(ResponseSet.from(setBuilder.build()));
  }

  return ResponseLinking.builder().docID(answerKey.docId()).responseSets(responseSets.build())
      .incompleteResponses(incompletes.build()).build();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:29,代码来源:ExactMatchEventArgumentLinkingAligner.java

示例12: align

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Generates an alignment between two collections of answers using this aligner.
 *
 * Every left and right answer will appear in the resulting alignment.  All left answers and right
 * answers with the same answerables under the left and right answerable extraction functions will
 * end up aligned.
 */
public <LeftTrueAnswerType extends LeftAnswerType, RightTrueAnswerType extends RightAnswerType>
AnswerAlignment<AnswerableType, LeftTrueAnswerType, RightTrueAnswerType> align(
    final Iterable<LeftTrueAnswerType> leftAnswers,
    final Iterable<RightTrueAnswerType> rightAnswers) {
  final Multimap<AnswerableType, LeftTrueAnswerType> equivClassesToLeft =
      Multimaps.index(leftAnswers, leftAnswerExtractor);
  final Multimap<AnswerableType, RightTrueAnswerType> equivClassesToRight =
      Multimaps.index(rightAnswers, rightAnswerExtractor);

  return AnswerAlignment.create(equivClassesToLeft, equivClassesToRight);
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:19,代码来源:AnswerableExtractorAligner.java

示例13: group

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private List<ArgumentGroup> group(List<ArgField> fields, List<Map.Entry<Argument, Long>> counts) {
    ListMultimap<String, Map.Entry<Argument, Long>> index = Multimaps.index(counts, entry ->
            fields.stream().map(f -> f.getToString().apply(entry)).collect(Collectors.joining(sep)));
    return index.asMap().entrySet().stream()
            .map(e -> new ArgumentGroup(e.getKey(), (List<Map.Entry<Argument, Long>>) e.getValue()))
            .collect(Collectors.toList());
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:8,代码来源:VerbSenseArgumentCounter.java

示例14: createSaleAccumulators

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private Collection<SaleAccumulator> createSaleAccumulators(Collection<SecurityLot> lots) {
    Multimap<TransactionDetail, SecurityLot> saleLots = Multimaps.index(lots, SecurityLot::getSale);
    List<SaleAccumulator> saleAccumulators = new ArrayList<>(saleLots.asMap().size());
    for (Entry<TransactionDetail, Collection<SecurityLot>> entry : saleLots.asMap().entrySet()) {
        if (isAllPurchasesAssigned(entry.getValue())) {
            saleAccumulators.add(new SaleAccumulator(entry.getKey(), entry.getValue()));
        }
        else {
            Transaction transaction = entry.getKey().getTransaction();
            logInfo(INCOMPLETE_LOTS, transaction.getSecurity().getName(), transaction.getDate());
            lots.removeAll(entry.getValue());
        }
    }
    return saleAccumulators;
}
 
开发者ID:jonestimd,项目名称:finances,代码行数:16,代码来源:LotValidator.java

示例15: getAttributes

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Converts protobuf attributes into thrift-generated attributes.
 *
 * @param offer Resource offer.
 * @return Equivalent thrift host attributes.
 */
public static IHostAttributes getAttributes(Offer offer) {
  // Group by attribute name.
  Multimap<String, Protos.Attribute> valuesByName =
      Multimaps.index(offer.getAttributesList(), ATTRIBUTE_NAME);

  return IHostAttributes.build(new HostAttributes(
      offer.getHostname(),
      FluentIterable.from(valuesByName.asMap().entrySet())
          .transform(ATTRIBUTE_CONVERTER)
          .toSet())
      .setSlaveId(offer.getSlaveId().getValue()));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:19,代码来源:Conversions.java


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