scala.collection.Map.get()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中scala.collection.Map.get()方法的一些代码示例,展示了Map.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Map.get()方法的具体详情如下:
包路径:scala.collection.Map
类名称:Map
方法名:get

Map.get介绍

暂无

代码示例

代码示例来源:origin: pinterest/doctorkafka

/**
 * Get the replica assignment for a given topic partition. This information should be retrieved
 * from zookeeper as topic metadata that we get from kafkaConsumer.listTopic() does not specify
 * the preferred leader for topic partitions.
 *
 * @param tp  topic partition
 * @return the list of brokers that host the replica
 */
private List<Integer> getReplicaAssignment(TopicPartition tp) {
 scala.collection.Map<Object, Seq<Object>> replicaAssignmentMap =
   getReplicaAssignmentForTopic(zkUtils, tp.topic());
 scala.Option<Seq<Object>> replicasOption = replicaAssignmentMap.get(tp.partition());
 Seq<Object> replicas = replicasOption.get();
 List<Object> replicasList = scala.collection.JavaConverters.seqAsJavaList(replicas);
 return replicasList.stream().map(obj -> (Integer) obj).collect(Collectors.toList());
}

代码示例来源:origin: shunfei/DCMonitor

public List<PartitionInfo> getPartitionInfos(String group, String topic) {
 Seq<String> singleTopic = JavaConversions.asScalaBuffer(Collections.singletonList(topic)).toSeq();
 scala.collection.Map<String, Seq<Object>> pidMap = ZkUtils.getPartitionsForTopics(zkClient, singleTopic);
 Option<Seq<Object>> partitions = pidMap.get(topic);
 if (partitions.get() == null) {
  return Collections.emptyList();
 }
 List<PartitionInfo> infos = Lists.newArrayList();
 for (Object o : JavaConversions.asJavaList(partitions.get())) {
  PartitionInfo info = getPartitionInfo(group, topic, Int.unbox(o));
  if (info != null) {
   infos.add(info);
  }
 }
 return infos;
}

代码示例来源:origin: kframework/k

@Override
public void apply(KToken k) {
  sb.append("\\dv{");
  convert(k.sort(), false);
  sb.append("}(");
  if (module.sortAttributesFor().get(k.sort()).getOrElse(() -> Att.empty()).getOptional("hook").orElse("").equals("STRING.String")) {
    sb.append(k.s());
  } else {
    sb.append(StringUtil.enquoteKString(k.s()));
  }
  sb.append(")");
}

代码示例来源:origin: kframework/k

@Override
  public void apply(KApply k) {
    String hook = module.attributesFor().get(k.klabel()).getOrElse(() -> Att.empty()).getOptional("hook").orElse("");
    if (hook.equals("SET.element")
        || hook.equals("LIST.element")
        || hook.equals("LIST.concat")
        || hook.equals("MAP.concat")
        || hook.equals("SET.concat")) {
      return;
    }
    if (hook.equals("MAP.element")) {
      apply(k.items().get(1));
      return;
    }
    super.apply(k);
  }
}.apply(term);

代码示例来源:origin: com.hurence.logisland/logisland-agent

private void verifySchemaTopic() {
  Set<String> topics = new HashSet<String>();
  topics.add(topic);
  // check # partition and the replication factor
  scala.collection.Map partitionAssignment = zkUtils.getPartitionAssignmentForTopics(
      JavaConversions.asScalaSet(topics).toSeq())
      .get(topic).get();
  if (partitionAssignment.size() != 1) {
    log.warn("The schema topic " + topic + " should have only 1 partition.");
  }
  if (((Seq) partitionAssignment.get(0).get()).size() < desiredReplicationFactor) {
    log.warn("The replication factor of the schema topic " + topic + " is less than the " +
        "desired one of " + desiredReplicationFactor + ". If this is a production " +
        "environment, it's crucial to add more brokers and increase the replication " +
        "factor of the topic.");
  }
  // check the retention policy
  Properties prop = AdminUtils.fetchEntityConfig(zkUtils, ConfigType.Topic(), topic);
  String retentionPolicy = prop.getProperty(LogConfig.CleanupPolicyProp());
  if (retentionPolicy == null || "compact".compareTo(retentionPolicy) != 0) {
    log.warn("The retention policy of the schema topic " + topic + " may be incorrect. " +
        "Please configure it with compact.");
  }
}

代码示例来源:origin: kframework/k

private void check(Production p) {
    if (p.att().contains(Attribute.CELL_KEY)) {
      for (ProductionItem i : mutable(p.items())) {
        if (i instanceof NonTerminal) {
          Sort sort = ((NonTerminal) i).sort();
          if (sort.name().endsWith("Cell")) {
            if (cells.contains(sort)) {
              Production cell = new ConfigurationInfoFromModule(module).cellProductionsFor().get(sort).get().head();
              errors.add(KEMException.compilerError("Cell " + cell.klabel().get() + " found twice in configuration.", p));
            }
            cells.add(sort);
          }
        }
      }
    }
  }
}

代码示例来源:origin: kframework/k

public static K toKASTTerm(Module mod, KApply kapp) {
    String       kastTerm  = ToKast.apply(kapp);
    Sort         finalSort = Sorts.K();
    Option<Sort> termSort  = mod.sortFor().get(kapp.klabel());
    if (! termSort.isEmpty()) {
      finalSort = termSort.get();
    }
    return KToken(kastTerm, finalSort);
  }
}

代码示例来源:origin: kframework/k

@Override
  public K apply(KVariable k) {
    if (freshVars.contains(k)) {
      Optional<Sort> s = k.att().getOptional(Sort.class);
      if (!s.isPresent()) {
        throw KEMException.compilerError("Fresh constant used without a declared sort.", k);
      }
      Option<KLabel> lbl = m.freshFunctionFor().get(s.get());
      if (!lbl.isDefined()) {
        throw KEMException.compilerError("No fresh generator defined for sort " + s, k);
      }
      return KApply(lbl.get(), KApply(KLabel("_+Int_"), FRESH, KToken(offsets.get(k).toString(), Sorts.Int())));
    }
    return super.apply(k);
  }
}.apply(term);

代码示例来源:origin: pinterest/doctorkafka

Seq<Object> seq = partitionAssignments.get(topic).get().get(partitionId).get();
Node[] nodes = JavaConverters.seqAsJavaList(seq).stream()
  .map(val -> new Node((Integer) val, "", -1)).toArray(Node[]::new);

代码示例来源:origin: kframework/k

Optional<KLabel> optLabel = klabelFromTerm(labelTerm);
if (optLabel.isPresent() && m.productionsFor().contains(optLabel.get())) {
  Collection<Production> productions = mutable(m.productionsFor().get(optLabel.get()).get());
  List<Term> rawArgs = lowerKList(((TermCons) child).get(1));
  assert rawArgs.stream().allMatch(ProductionReference.class::isInstance);

代码示例来源:origin: kframework/k

private static K omitTerm(Module mod, KApply kapp) {
  Sort finalSort = Sorts.K();
  Option<Sort> termSort = mod.sortFor().get(kapp.klabel());
  if (! termSort.isEmpty()) {
    finalSort = termSort.get();
  }
  return KToken(kapp.klabel().name(), finalSort);
}

代码示例来源:origin: kframework/k

private K tokenizeTerm(Module mod, KApply kapp) {
  Module unparsingModule = RuleGrammarGenerator.getCombinedGrammar(mod, false).getExtensionModule();
  String tokenizedTerm   = unparseTerm(kapp, unparsingModule, ColorSetting.OFF);
  Sort   finalSort       = Sorts.K();
  Option<Sort> termSort  = mod.sortFor().get(kapp.klabel());
  if (! termSort.isEmpty()) {
    finalSort = termSort.get();
  }
  return KToken(tokenizedTerm, finalSort);
}

代码示例来源:origin: kframework/k

if (threadsCellSet instanceof KApply) {
  KLabel collectionLabel = collectionFor.get(((KApply)threadsCellSet).klabel());
  KLabel unitLabel = KLabel(m.attributesFor().get(collectionLabel).get().get("unit"));
  List<K> threads = Assoc.flatten(collectionLabel, Collections.singletonList(threadsCellSet), unitLabel);
  K firstConcreteThread = null;

代码示例来源:origin: kframework/k

klabelsForEachPredicate = new HashMap<>();
for (KLabel functionLabel : rules.keySet()) {
  if (mainModule.attributesFor().get(functionLabel).getOrElse(() -> Att()).contains("klabelPredicate")) {
    klabelsForEachPredicate.put(functionLabel.name(), computeKLabelsForPredicate(functionRules.get(functionLabel)));
    String hook = mainModule.attributesFor().get(functionLabel).getOrElse(() -> Att()).<String>getOptional(Attribute.HOOK_KEY).orElse(".");
    if (hook.equals("KREFLECTION.fresh")) {
      sb.append(conn).append("freshFunction (sort: string) (config: k) (counter: Z.t) : k = match sort with \n");

代码示例来源:origin: kframework/k

Sort.of(module.productionsFor().get(klabel).get().head().sort()),
(KLabelConstant) convertedKLabel,
KLabelConstant.of(org.kframework.backend.java.kil.KLabel.parse(module.attributesFor().get(klabel).get().<String>get(Att.unit())), global.getDefinition()),
global);

代码示例来源:origin: kframework/k

list = newDotVariable(m.productionsFor().get(collectionLabel).get().head().sort());

代码示例来源:origin: kframework/k

continue;
if (m.attributesFor().get(k.klabel()).getOrElse(() -> Att()).contains("klabelPredicate")) {
  if (k.klist().size() == 1 && k.klist().items().get(0) instanceof InjectedKLabel) {
    InjectedKLabel injection = (InjectedKLabel) k.klist().items().get(0);

代码示例来源:origin: kframework/k

sb.append("\n");
for (Sort sort : iterable(module.definedSorts())) {
  Att att = module.sortAttributesFor().get(sort).getOrElse(() -> KORE.Att());
  collectAttributes(attributes, att);
  Att att = module.sortAttributesFor().get(sort).getOrElse(() -> KORE.Att());
  if (att.contains(Attribute.HOOK_KEY)) {
    if (collectionSorts.contains(att.get(Attribute.HOOK_KEY))) {
Set<Production> overloads = new HashSet<>();
for (Production lesser : iterable(module.overloads().elements())) {
  for (Production greater : iterable(module.overloads().relations().get(lesser).getOrElse(() -> Collections.<Production>Set()))) {
    overloads.add(greater);
  Att sortAtt = module.sortAttributesFor().get(sort).getOrElse(() -> KORE.Att());
  if (!hasToken && sortAtt.contains("token")) {
    numTerms++;
  for (Production greater : iterable(module.overloads().relations().get(lesser).getOrElse(() -> Collections.<Production>Set()))) {
    sb.append("  axiom{R} \\equals{");
    convert(greater.sort(), greater);

代码示例来源:origin: kframework/k

String hookAtt = mod.sortAttributesFor().get(expectedSort).getOrElse(() -> Att()).getOptional("hook").orElse("");
if (hookAtt.equals("MAP.Map") || hookAtt.equals("SET.Set") || hookAtt.equals("LIST.List")) {
  for (KLabel collectionLabel : collectionFor.keySet()) {

代码示例来源:origin: kframework/k

String cellName = label.s();
Sort sort = Sort(getSortOfCell(cellName));
Option<Set<Production>> initializerProduction = m.productionsFor().get(KLabel(getInitLabel(sort)));
if (initializerProduction.isDefined()) {
  Set<Production> realProds = stream(initializerProduction.get()).filter(p -> !p.att().contains("recordPrd", Production.class)).collect(Collections.toSet());

相关文章