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


Java Map类代码示例

本文整理汇总了Java中scala.collection.Map的典型用法代码示例。如果您正苦于以下问题:Java Map类的具体用法?Java Map怎么用?Java Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: changeTopicPartition

import scala.collection.Map; //导入依赖的package包/类
/**
 * 修改主题分区副本数
 *
 * @param topic       主题
 * @param partitions  分区
 * @param replication 副本
 */
private static void changeTopicPartition(String topic, int partitions, int replication) {
    // 获取代理元数据信息
    Seq<BrokerMetadata> brokerMeta = AdminUtils.getBrokerMetadatas(zkUtils, AdminUtils
            .getBrokerMetadatas$default$2(), AdminUtils.getBrokerMetadatas$default$3());
    // 生成分区副本分配方案
    Map<Object, Seq<Object>> replicaAssign = AdminUtils.assignReplicasToBrokers(brokerMeta, partitions,
            replication, AdminUtils.assignReplicasToBrokers$default$4(), AdminUtils
                    .assignReplicasToBrokers$default$5());
    // 修改分区副本分配方案
    AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkUtils, topic, replicaAssign, null, true);
}
 
开发者ID:wngn123,项目名称:wngn-jms-kafka,代码行数:19,代码来源:TopicOperator.java

示例2: getTopicConfigProperties

import scala.collection.Map; //导入依赖的package包/类
private Properties getTopicConfigProperties(final String changelog) {
    // Note: You must initialize the ZkClient with ZKStringSerializer.  If you don't, then
    // createTopics() will only seem to work (it will return without error).  The topic will exist in
    // only ZooKeeper and will be returned when listing topics, but Kafka itself does not create the
    // topic.
    final ZkClient zkClient = new ZkClient(
            CLUSTER.zKConnectString(),
            DEFAULT_ZK_SESSION_TIMEOUT_MS,
            DEFAULT_ZK_CONNECTION_TIMEOUT_MS,
            ZKStringSerializer$.MODULE$);
    try {
        final boolean isSecure = false;
        final ZkUtils zkUtils = new ZkUtils(zkClient, new ZkConnection(CLUSTER.zKConnectString()), isSecure);

        final Map<String, Properties> topicConfigs = AdminUtils.fetchAllTopicConfigs(zkUtils);
        final Iterator it = topicConfigs.iterator();
        while (it.hasNext()) {
            final Tuple2<String, Properties> topicConfig = (Tuple2<String, Properties>) it.next();
            final String topic = topicConfig._1;
            final Properties prop = topicConfig._2;
            if (topic.equals(changelog)) {
                return prop;
            }
        }
        return new Properties();
    } finally {
        zkClient.close();
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:30,代码来源:InternalTopicIntegrationTest.java

示例3: createOrUpdateTopic

import scala.collection.Map; //导入依赖的package包/类
@Override
public void createOrUpdateTopic(String topic, int replicationFactor, int partitions) {
    logger.debug("Creating topic {} with replication {} and {} partitions", topic, replicationFactor, partitions);
    Topic.validate(topic);
    Seq<Object> brokerList = ZkUtils.getSortedBrokerList(zkClient);
    Map<Object, Seq<Object>> partitionReplicaAssignment = AdminUtils.assignReplicasToBrokers(brokerList,
            partitions, replicationFactor, AdminUtils.assignReplicasToBrokers$default$4(),
            AdminUtils.assignReplicasToBrokers$default$5());
    AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkClient, topic, partitionReplicaAssignment,
            AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK$default$4(),
            AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK$default$5());
    logger.debug("Topic {} created", topic);
}
 
开发者ID:Stratio,项目名称:Decision,代码行数:14,代码来源:KafkaTopicService.java

示例4: Authorship

import scala.collection.Map; //导入依赖的package包/类
/**
 * Lazily initializes the authorship maps when needed.
 * This needs to be called manually before any authorship getters
 */
Authorship(Map<String, Object> authorshipMap) {
  Map<String, Object> comb = ScalaUtils.optionMap(authorshipMap.get("combination_authorship"));
  Map<String, Object> bas = ScalaUtils.optionMap(authorshipMap.get("basionym_authorship"));
  // in case of just a combination author it comes as the basionym author, swap!
  String authorship = (String) authorshipMap.get("value").get();
  if (comb.isEmpty() && !bas.isEmpty() && !authorship.startsWith("(")) {
    combination = bas;
    basionym = comb;
  } else {
    combination = comb;
    basionym = bas;
  }
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:18,代码来源:Authorship.java

示例5: authors

import scala.collection.Map; //导入依赖的package包/类
public static List<String> authors(Map<String, Object> auth, boolean ex) {
  String key = ex ? "ex_authors" : "authors";
  if (auth.contains(key)) {
    Option val = ScalaUtils.unwrap(auth.get(key));
    if (val.isDefined()) {
      return JavaConversions.seqAsJavaList((scala.collection.immutable.List) val.get());
    }
  }
  return Lists.newArrayList();
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:11,代码来源:Authorship.java

示例6: mapValueString

import scala.collection.Map; //导入依赖的package包/类
/**
 * Return the nested map value for the key and use "value" as key for the second,nested map.
 */
private static String mapValueString(Map map, String key) {
  Option val = ScalaUtils.unwrap(map.get(key));
  if (val.isDefined()) {
    return ScalaUtils.mapString((Map)val.get(), "value");
  }
  return null;
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:11,代码来源:Authorship.java

示例7: setAuthorship

import scala.collection.Map; //导入依赖的package包/类
private void setAuthorship(org.gbif.nameparser.api.Authorship auth, Map<String, Object> map) {
  // if ex authors exist we will swap them to follow the botanical order convention by default
  // as ex authors are mainly used in the botanical world
  List<String> ex = Lists.newArrayList(Authorship.authors(map, true));
  if (ex.isEmpty()) {
    auth.setAuthors(Lists.newArrayList(Authorship.authors(map, false)));
  } else {
    auth.setAuthors(ex);
    auth.setExAuthors(Lists.newArrayList(Authorship.authors(map, false)));
  }
  auth.setYear(Authorship.year(map));
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:13,代码来源:NameParserGNA.java

示例8: create

import scala.collection.Map; //导入依赖的package包/类
public static ScinameMap create(String verbatim, ScientificNameParser.Result result) {
  Object details = result.detailed();
  if (details instanceof org.json4s.JsonAST.JArray) {
    org.json4s.JsonAST.JArray array = (org.json4s.JsonAST.JArray) details;
    return new ScinameMap((scala.collection.immutable.Map) array.values().iterator().next());

  } else {
    // we should never get here. If we do this is a bug that needs fixed!
    LOG.info(result.render(false, false));
    throw new RuntimeException("GNA Parser details of unkown type " + details.getClass().getCanonicalName());
  }
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:13,代码来源:ScinameMap.java

示例9: infraSpecificEpithet

import scala.collection.Map; //导入依赖的package包/类
public Option<Epithet> infraSpecificEpithet() {
  Option opt = ScalaUtils.unwrap(map.get("infraspecific_epithets"));
  if (opt.isDefined()) {
    scala.collection.immutable.List list = (scala.collection.immutable.List) opt.get();
    if (list.isEmpty()) {
      return Option.empty();
    }
    return Option.apply(new Epithet((Map) list.last()));
  }
  return Option.empty();
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:12,代码来源:ScinameMap.java

示例10: epithet

import scala.collection.Map; //导入依赖的package包/类
private Option<Epithet> epithet(String key) {
  Option val = ScalaUtils.unwrap(map.get(key));
  if (val.isDefined()) {
    return Option.apply(new Epithet((Map) val.get()));
  }
  return Option.empty();
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:8,代码来源:ScinameMap.java

示例11: optionMap

import scala.collection.Map; //导入依赖的package包/类
/**
 * Takes a scala map, None or Some of a map and returns a scala map which will be empty in case of None values.
 * Deals with nested, wrapped Options.
 * @return a scala map, empty or full but never null
 */
public static Map<String, Object> optionMap(Object obj) {
  if (obj instanceof Option) {
    Option opt = unwrap( (Option) obj);
    return opt.isEmpty() ? EMPTY_MAP : (Map<String, Object>) opt.get();

  } else if (obj instanceof Map) {
    return (Map) obj;
  }
  return EMPTY_MAP;
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:16,代码来源:ScalaUtils.java

示例12: mapString

import scala.collection.Map; //导入依赖的package包/类
/**
 * @return the string value of a map entry or null if not existing or with value None
 */
public static String mapString(Map map, String key) {
    Option val = unwrap(map.get(key));
    if (val.isDefined()) {
      return (String) val.get();
    }
    return null;
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:11,代码来源:ScalaUtils.java

示例13: Epithet

import scala.collection.Map; //导入依赖的package包/类
public Epithet(Map map) {
  epithet = ScalaUtils.mapString(map, "value");
  parent = ScalaUtils.mapString(map, "parent");
  rank = ScalaUtils.mapString(map, "rank");
  if (map.contains("authorship")) {
    authorship = new Authorship((Map<String, Object>) map.get("authorship").get());
  } else {
    authorship = null;
  }
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:11,代码来源:Epithet.java

示例14: fromMap

import scala.collection.Map; //导入依赖的package包/类
public static <K, V> ImmutableMap<K, V> fromMap(Map<K, V> m) {
    return ImmutableMap.copyOf(JavaConverters.mapAsJavaMapConverter(m).asJava());
}
 
开发者ID:otto-de,项目名称:pact-jvm-provider-generic,代码行数:4,代码来源:ScalaInterop.java

示例15: year

import scala.collection.Map; //导入依赖的package包/类
public static String year(Map<String, Object> auth) {
  return mapValueString(auth,"year");
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:4,代码来源:Authorship.java


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