本文整理汇总了Java中scala.collection.Map类的典型用法代码示例。如果您正苦于以下问题:Java Map类的具体用法?Java Map怎么用?Java Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Map类属于scala.collection包,在下文中一共展示了Map类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ScinameMap
import scala.collection.Map; //导入依赖的package包/类
private ScinameMap(Map map) {
this.map = map;
}
开发者ID:gbif,项目名称:name-parser,代码行数:4,代码来源:ScinameMap.java
示例17: vsensor
import scala.collection.Map; //导入依赖的package包/类
public static VSensorConfig vsensor(VsConf vs){
VSensorConfig v=new VSensorConfig();
v.setMainClass(vs.processing().className());
v.setDescription(vs.description());
v.setName(vs.name());
v.setIsTimeStampUnique(vs.processing().uniqueTimestamp());
if (vs.poolSize().isDefined())
v.setLifeCyclePoolSize(((Integer)vs.poolSize().get()));
if (vs.processing().rate().isDefined())
v.setOutputStreamRate(((Integer)vs.processing().rate().get()));
v.setPriority(vs.priority());
KeyValueImp [] addr=new KeyValueImp[vs.address().size()];
Iterable<String> keys=JavaConversions.asJavaIterable(vs.address().keys());
int i=0;
for (String k:keys){
addr[i]=new KeyValueImp(k,vs.address().apply(k));
i++;
}
v.setAddressing(addr);
InputStream[] is=new InputStream[vs.streams().size()];
for (int j=0;j<is.length;j++){
is[j]=stream(vs.streams().apply(j));
}
v.setInputStreams(is);
if (vs.processing().webInput().isDefined()){
WebInputConf wic=vs.processing().webInput().get();
v.setWebParameterPassword(wic.password());
WebInput[] wi=new WebInput[wic.commands().size()];
for (int j=0;j<wi.length;j++){
wi[j]=webInput(wic.commands().apply(j));
}
v.setWebInput(wi);
}
DataField [] out=new DataField[(vs.processing().output().size())];
for (int j=0;j<out.length;j++){
out[j]=dataField(vs.processing().output().apply(j));
}
v.setOutputStructure(out);
Map<String,String> init=vs.processing().initParams();
ArrayList<KeyValue> ini=new ArrayList<KeyValue>();
Iterable<String> initkeys=JavaConversions.asJavaIterable(init.keys());
for (String ik:initkeys){
logger.trace("keys:"+ik);
ini.add(new KeyValueImp(ik.toLowerCase(),init.apply(ik)));
}
v.setMainClassInitialParams(ini);
StorageConfig st=new StorageConfig();
if (vs.storageSize().isDefined())
st.setStorageSize(vs.storageSize().get());
if (vs.storage().isDefined()){
StorageConf sc=vs.storage().get();
if (sc.identifier().isDefined())
st.setIdentifier(sc.identifier().get());
st.setJdbcDriver(sc.driver());
st.setJdbcURL(sc.url());
st.setJdbcUsername(sc.user());
st.setJdbcPassword(sc.pass());
}
if (st.getStorageSize()!=null || st.getJdbcURL()!=null)
v.setStorage(st);
return v;
}
开发者ID:LSIR,项目名称:gsn,代码行数:64,代码来源:BeansInitializer.java
示例18: getMap
import scala.collection.Map; //导入依赖的package包/类
@Override
public <K, V> Map<K, V> getMap(int i) {
return valueRow.getMap(i);
}
开发者ID:splicemachine,项目名称:spliceengine,代码行数:5,代码来源:IndexValueRow.java
示例19: getJavaMap
import scala.collection.Map; //导入依赖的package包/类
@Override
public <K, V> java.util.Map<K, V> getJavaMap(int i) {
return valueRow.getJavaMap(i);
}
开发者ID:splicemachine,项目名称:spliceengine,代码行数:5,代码来源:IndexValueRow.java
示例20: getValuesMap
import scala.collection.Map; //导入依赖的package包/类
@Override
public <T> scala.collection.immutable.Map<String, T> getValuesMap(Seq<String> seq) {
return valueRow.getValuesMap(seq);
}
开发者ID:splicemachine,项目名称:spliceengine,代码行数:5,代码来源:IndexValueRow.java
注:本文中的scala.collection.Map类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论