本文整理了Java中scala.collection.immutable.Map
类的一些代码示例,展示了Map
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Map
类的具体详情如下:
包路径:scala.collection.immutable.Map
类名称:Map
暂无
代码示例来源:origin: twosigma/beakerx
@Override
public String getSparkAppId() {
RuntimeConfig conf = getOrCreate().conf();
return conf.getAll().get(SPARK_APP_ID).get();
}
代码示例来源:origin: linkedin/kafka-monitor
private static void reassignPartitions(KafkaZkClient zkClient, Collection<Broker> brokers, String topic, int partitionCount, int replicationFactor) {
scala.collection.mutable.ArrayBuffer<BrokerMetadata> brokersMetadata = new scala.collection.mutable.ArrayBuffer<>(brokers.size());
for (Broker broker : brokers) {
brokersMetadata.$plus$eq(new BrokerMetadata(broker.id(), broker.rack()));
}
scala.collection.Map<Object, Seq<Object>> assignedReplicas =
AdminUtils.assignReplicasToBrokers(brokersMetadata, partitionCount, replicationFactor, 0, 0);
scala.collection.immutable.Map<TopicPartition, Seq<Object>> newAssignment = new scala.collection.immutable.HashMap<>();
scala.collection.Iterator<scala.Tuple2<Object, scala.collection.Seq<Object>>> it = assignedReplicas.iterator();
while (it.hasNext()) {
scala.Tuple2<Object, scala.collection.Seq<Object>> scalaTuple = it.next();
TopicPartition tp = new TopicPartition(topic, (Integer) scalaTuple._1);
newAssignment = newAssignment.$plus(new scala.Tuple2<>(tp, scalaTuple._2));
}
scala.collection.immutable.Set<String> topicList = new scala.collection.immutable.Set.Set1<>(topic);
scala.collection.Map<Object, scala.collection.Seq<Object>> currentAssignment = zkClient.getPartitionAssignmentForTopics(topicList).apply(topic);
String currentAssignmentJson = formatAsReassignmentJson(topic, currentAssignment);
String newAssignmentJson = formatAsReassignmentJson(topic, assignedReplicas);
LOG.info("Reassign partitions for topic " + topic);
LOG.info("Current partition replica assignment " + currentAssignmentJson);
LOG.info("New partition replica assignment " + newAssignmentJson);
zkClient.createPartitionReassignment(newAssignment);
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public scala.collection.immutable.Map<String, String> immutableScalaPut()
{
int localSize = this.size;
String[] localElements = this.elements;
scala.collection.immutable.Map<String, String> map = HashMap$.MODULE$.empty();
for (int i = 0; i < localSize; i++)
{
map = map.updated(localElements[i], "dummy");
}
return map;
}
}
代码示例来源:origin: ch.epfl.gsn/gsn-core
public static AddressBean address(WrapperConf w){
KeyValueImp [] p=new KeyValueImp[w.params().size()];
Iterable<String> keys=JavaConversions.asJavaIterable(w.params().keys());
int i=0;
for (String k:keys){
p[i]=new KeyValueImp(k,w.params().apply(k));
i++;
}
AddressBean a = new AddressBean(w.wrapper(),p);
if(w.partialKey().isDefined()){
a.setPartialOrderKey(w.partialKey().get());
}
DataField [] out=new DataField[(w.output().size())];
for (int j=0;j<out.length;j++){
out[j]=dataField(w.output().apply(j));
}
a.setVsconfig(out);
return a;
}
代码示例来源:origin: apache/samza
/**
* Directory loggedStoreDir associated with the logged store storeName is determined to be valid
* if all of the following conditions are true.
* a) If the store has to be persisted to disk.
* b) If there is a valid offset file associated with the logged store.
* c) If the logged store has not gone stale.
*
* @return true if the logged store is valid, false otherwise.
*/
private boolean isLoggedStoreValid(String storeName, File loggedStoreDir) {
long changeLogDeleteRetentionInMs = StorageConfig.DEFAULT_CHANGELOG_DELETE_RETENTION_MS();
if (new StorageConfig(config).getChangeLogDeleteRetentionsInMs().get(storeName).isDefined()) {
changeLogDeleteRetentionInMs =
(long) new StorageConfig(config).getChangeLogDeleteRetentionsInMs().get(storeName).get();
}
return this.taskStores.get(storeName).getStoreProperties().isPersistedToDisk()
&& StorageManagerUtil.isOffsetFileValid(loggedStoreDir, OFFSET_FILE_NAME) && !StorageManagerUtil.isStaleStore(
loggedStoreDir, OFFSET_FILE_NAME, changeLogDeleteRetentionInMs, clock.currentTimeMillis());
}
代码示例来源:origin: pac4j/play-pac4j
/**
* We retrieve the body apart from the request. Otherwise, there is an issue in casting the body between Scala and Java.
*
* @param requestHeader the request without the body
* @param body the body (maybe)
* @param sessionStore the session store
*/
public PlayWebContext(final RequestHeader requestHeader, final Object body, final SessionStore<org.pac4j.play.PlayWebContext> sessionStore) {
this(JavaHelpers$.MODULE$.createJavaContext(requestHeader, JavaHelpers$.MODULE$.createContextComponents()), sessionStore);
this.formParameters = new HashMap<>();
if (body instanceof AnyContentAsFormUrlEncoded) {
final scala.collection.immutable.Map<String, Seq<String>> parameters = ((AnyContentAsFormUrlEncoded) body).asFormUrlEncoded().get();
for (final String key : ScalaCompatibility.scalaSetToJavaSet(parameters.keySet())) {
final Seq<String> v = parameters.get(key).get();
final String[] values = new String[v.size()];
v.copyToArray(values);
formParameters.put(key, values);
}
}
}
代码示例来源:origin: linkedin/kafka-monitor
private static List<PartitionInfo> getPartitionInfo(KafkaZkClient zkClient, String topic) {
scala.collection.immutable.Set<String> topicList = new scala.collection.immutable.Set.Set1<>(topic);
scala.collection.Map<Object, scala.collection.Seq<Object>> partitionAssignments =
zkClient.getPartitionAssignmentForTopics(topicList).apply(topic);
List<PartitionInfo> partitionInfoList = new ArrayList<>();
scala.collection.Iterator<scala.Tuple2<Object, scala.collection.Seq<Object>>> it = partitionAssignments.iterator();
while (it.hasNext()) {
scala.Tuple2<Object, scala.collection.Seq<Object>> scalaTuple = it.next();
Integer partition = (Integer) scalaTuple._1();
scala.Option<Object> leaderOption = zkClient.getLeaderForPartition(new TopicPartition(topic, partition));
Node leader = leaderOption.isEmpty() ? null : new Node((Integer) leaderOption.get(), "", -1);
Node[] replicas = new Node[scalaTuple._2().size()];
for (int i = 0; i < replicas.length; i++) {
Integer brokerId = (Integer) scalaTuple._2().apply(i);
replicas[i] = new Node(brokerId, "", -1);
}
partitionInfoList.add(new PartitionInfo(topic, partition, leader, replicas, null));
}
return partitionInfoList;
}
代码示例来源:origin: shunfei/DCMonitor
private long getTopicLogSize(String topic, int pid) {
Option<Object> o = ZkUtils.getLeaderForPartition(zkClient, topic, pid);
if (o.isEmpty() || o.get() == null) {
log.error("No broker for partition %s - %s", topic, pid);
return 0;
}
Integer leaderId = Int.unbox(o.get());
SimpleConsumer consumer = consumerMap.get(leaderId);
if (consumer == null) {
consumer = createSimpleConsumer(leaderId);
}
// createSimpleConsumer may fail.
if (consumer == null) {
return 0;
}
consumerMap.put(leaderId, consumer);
TopicAndPartition topicAndPartition = new TopicAndPartition(topic, pid);
PartitionOffsetRequestInfo requestInfo = new PartitionOffsetRequestInfo(OffsetRequest.LatestTime(), 1);
OffsetRequest request = new OffsetRequest(
new Map1<TopicAndPartition, PartitionOffsetRequestInfo>(topicAndPartition, requestInfo),
0,
Request.OrdinaryConsumerId()
);
OffsetResponse response = consumer.getOffsetsBefore(request);
PartitionOffsetsResponse offsetsResponse = response.partitionErrorAndOffsets().get(topicAndPartition).get();
return scala.Long.unbox(offsetsResponse.offsets().head());
}
代码示例来源:origin: apache/incubator-sentry
public scala.collection.immutable.Set<Acl> getAcls(final Resource resource) {
final Option<scala.collection.immutable.Set<Acl>> acls = getAcls().get(resource);
if (acls.nonEmpty())
return acls.get();
return new scala.collection.immutable.HashSet<Acl>();
}
代码示例来源:origin: goldmansachs/gs-collections
@Benchmark
public void get()
{
int localSize = this.size;
String[] localElements = this.elements;
Map<String, String> localScalaMap = this.scalaMap;
for (int i = 0; i < localSize; i++)
{
if (!localScalaMap.get(localElements[i]).isDefined())
{
throw new AssertionError(i);
}
}
}
}
代码示例来源:origin: com.typesafe.play/play-java_2.10
private PathBindable<?> pathBindableFor(Class<?> clazz) {
PathBindable<?> builtIn = Scala.orNull(PathBindable$.MODULE$.pathBindableRegister().get(clazz));
if (builtIn != null) {
return builtIn;
} else if (play.mvc.PathBindable.class.isAssignableFrom(clazz)) {
return PathBindable$.MODULE$.javaPathBindable((ClassTag) ClassTag$.MODULE$.apply(clazz));
} else if (clazz.equals(Object.class)) {
// Special case for object, treat as a string
return PathBindable.bindableString$.MODULE$;
} else {
throw new IllegalArgumentException("Don't know how to bind argument of type " + clazz);
}
}
代码示例来源:origin: apache/samza
int asyncTaskCount = taskInstances.values().count(new AbstractFunction1<TaskInstance, Object>() {
@Override
public Boolean apply(TaskInstance t) {
if (asyncTaskCount > 0 && asyncTaskCount < taskInstances.size()) {
throw new SamzaException("Mixing StreamTask and AsyncStreamTask is not supported");
代码示例来源:origin: com.typesafe.akka/akka-http-core_2.11
public static scala.collection.immutable.Map<String, String> convertMapToScala(Map<String, String> map) {
return emptyMap.$plus$plus(scala.collection.JavaConverters.mapAsScalaMapConverter(map).asScala());
}
@SuppressWarnings("unchecked") // contains an upcast
代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client
private Map<String, String> buildSslConfig(JsonObject config) {
Map<String, String> sslConfig = Map$.MODULE$.empty();
if (config.getString("sslMode")!= null) {
sslConfig = sslConfig.$plus(Tuple2.apply("sslmode", config.getString("sslMode")));
}
if (config.getString("sslRootCert") != null) {
sslConfig = sslConfig.$plus(Tuple2.apply("sslrootcert", config.getString("sslRootCert")));
}
return sslConfig;
}
代码示例来源:origin: linkedin/kafka-monitor
private static scala.collection.Map<Object, scala.collection.Seq<Object>> getPartitionAssignment(KafkaZkClient zkClient, String topic) {
scala.collection.immutable.Set<String> topicList = new scala.collection.immutable.Set.Set1<>(topic);
return zkClient.getPartitionAssignmentForTopics(topicList).apply(topic);
}
代码示例来源:origin: org.mule.modules/edi-module-common
/**
* Build metadata for structures list.
*
* @param root
* @param structKey key for map of structure lists in root
* @param read input version of structure data
*/
public void buildStructures(DynamicObjectBuilder<?> root, String structKey, boolean read) {
DynamicObjectBuilder<?> structuresMap = root.addDynamicObjectField(structKey);
Iterator<String> keys = schema.structures().keysIterator();
while (!keys.isEmpty()) {
Structure structure = (Structure)schema.structures().apply(keys.next());
DynamicObjectBuilder<?> tranMap = structuresMap.addList(structure.ident()).
ofDynamicObject(structure.ident());
buildStructure(structure, read, tranMap);
}
}
代码示例来源:origin: ch.epfl.gsn/gsn-core
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++;
代码示例来源:origin: pac4j/play-pac4j
/**
* We retrieve the body apart from the request. Otherwise, there is an issue in casting the body between Scala and Java.
*
* @param requestHeader the request without the body
* @param body the body (maybe)
* @param sessionStore the session store
*/
public PlayWebContext(final RequestHeader requestHeader, final Object body, final SessionStore<org.pac4j.play.PlayWebContext> sessionStore) {
this(JavaHelpers$.MODULE$.createJavaContext(requestHeader, JavaHelpers$.MODULE$.createContextComponents()), sessionStore);
this.formParameters = new HashMap<>();
if (body instanceof AnyContentAsFormUrlEncoded) {
final scala.collection.immutable.Map<String, Seq<String>> parameters = ((AnyContentAsFormUrlEncoded) body).asFormUrlEncoded().get();
for (final String key : ScalaCompatibility.scalaSetToJavaSet(parameters.keySet())) {
final Seq<String> v = parameters.get(key).get();
final String[] values = new String[v.size()];
v.copyToArray(values);
formParameters.put(key, values);
}
}
}
代码示例来源:origin: com.typesafe.play/play-java_2.11
private PathBindable<?> pathBindableFor(Class<?> clazz) {
PathBindable<?> builtIn = Scala.orNull(PathBindable$.MODULE$.pathBindableRegister().get(clazz));
if (builtIn != null) {
return builtIn;
} else if (play.mvc.PathBindable.class.isAssignableFrom(clazz)) {
return PathBindable$.MODULE$.javaPathBindable((ClassTag) ClassTag$.MODULE$.apply(clazz));
} else if (clazz.equals(Object.class)) {
// Special case for object, treat as a string
return PathBindable.bindableString$.MODULE$;
} else {
throw new IllegalArgumentException("Don't know how to bind argument of type " + clazz);
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
int asyncTaskCount = taskInstances.values().count(new AbstractFunction1<TaskInstance, Object>() {
@Override
public Boolean apply(TaskInstance t) {
if (asyncTaskCount > 0 && asyncTaskCount < taskInstances.size()) {
throw new SamzaException("Mixing StreamTask and AsyncStreamTask is not supported");
内容来源于网络,如有侵权,请联系作者删除!