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


Java Seq类代码示例

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


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

示例1: convertPhrasesToTokens

import scala.collection.Seq; //导入依赖的package包/类
private Seq<KoreanToken> convertPhrasesToTokens(Seq<KoreanPhrase> phrases) {
    KoreanToken[] tokens = new KoreanToken[phrases.length()];

    Iterator<KoreanPhrase> iterator = phrases.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        KoreanPhrase phrase = iterator.next();
        tokens[i++] = new KoreanToken(phrase.text(), phrase.pos(), phrase.offset(), phrase.length(), scala.Option.apply(null), false);
    }

    Arrays.sort(tokens, (o1, o2) -> {
        if(o1.offset()== o2.offset())
            return 0;
        return o1.offset()< o2.offset()? -1 : 1;
    });

    return JavaConverters.asScalaBuffer(Arrays.asList(tokens)).toSeq();
}
 
开发者ID:open-korean-text,项目名称:elasticsearch-analysis-openkoreantext,代码行数:19,代码来源:OpenKoreanTextPhraseExtractor.java

示例2: bindings

import scala.collection.Seq; //导入依赖的package包/类
@Override
public Seq<Binding<?>> bindings(Environment environment, Configuration configuration) {

    Binding<EbeanServer> ebeanBinding = bind(EbeanServer.class)
            .qualifiedWith(PushServicesEbeanServer.class)
            .toProvider(PushServicesEbeanServerProvider.class);

    Binding<ApplicationLifecycleListener> lifecycleBinding = bind(ApplicationLifecycleListener.class)
            .toProvider(PushApplicationLifecycleProvider.class)
            .eagerly();

    Binding<TaskQueueScheduler> taskqueueBinding = bind(TaskQueueScheduler.class)
            .toSelf();

    return seq(ebeanBinding, lifecycleBinding, taskqueueBinding);
}
 
开发者ID:splendidbits,项目名称:play-pushservices,代码行数:17,代码来源:PushServicesModule.java

示例3: bindings

import scala.collection.Seq; //导入依赖的package包/类
@Override
public Seq<Binding<?>> bindings(Environment environment, Configuration configuration) {
    GlobalParams.AWS_ACCESS_KEY = Scala.orNull(configuration.getString("AWS_ACCESS_KEY", scala.Option.empty()));
    GlobalParams.AWS_SECRET_KEY = Scala.orNull(configuration.getString("AWS_SECRET_KEY", scala.Option.empty()));
    GlobalParams.AWS_S3_BUCKET = Scala.orNull(configuration.getString("AWS_S3_BUCKET", scala.Option.empty()));

    String accessKey = GlobalParams.AWS_ACCESS_KEY;
    String secretKey = GlobalParams.AWS_SECRET_KEY;
    s3Bucket = GlobalParams.AWS_S3_BUCKET;

    if ((accessKey != null) && (secretKey != null)) {
        awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
        amazonS3 = new AmazonS3Client(awsCredentials);

        Logger.info("Using S3 Bucket: " + s3Bucket);
    }
    return seq(
            bind(S3Plugin.class).to(S3PluginImpl.class)
    );
}
 
开发者ID:webinerds,项目名称:s3-proxy-chunk-upload,代码行数:21,代码来源:S3Module.java

示例4: getReplicaAssignmentForTopic

import scala.collection.Seq; //导入依赖的package包/类
private scala.collection.Map<Object, Seq<Object>> getReplicaAssignmentForTopic(
    ZkUtils zkUtils, String topic) {
  if (topicPartitionAssignments.containsKey(topic)) {
    return topicPartitionAssignments.get(topic);
  }
  List<String> topics = new ArrayList<>();
  topics.add(topic);
  Seq<String> topicsSeq = scala.collection.JavaConverters.asScalaBuffer(topics).toSeq();

  scala.collection.mutable.Map<String, scala.collection.Map<Object, Seq<Object>>> assignments;
  assignments = zkUtils.getPartitionAssignmentForTopics(topicsSeq);

  scala.collection.Map<Object, Seq<Object>> partitionAssignment = assignments.get(topic).get();
  topicPartitionAssignments.put(topic, partitionAssignment);
  return partitionAssignment;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:17,代码来源:KafkaClusterManager.java

示例5: getAssignmentPlan

import scala.collection.Seq; //导入依赖的package包/类
private scala.collection.Map<TopicAndPartition, Seq<Object>> getAssignmentPlan(
    Map<TopicPartition, Integer[]> replicasMap) {
  scala.collection.mutable.HashMap<TopicAndPartition, Seq<Object>> result =
      new scala.collection.mutable.HashMap<>();

  for (Map.Entry<TopicPartition, Integer[]> entry : replicasMap.entrySet()) {
    TopicPartition tp = entry.getKey();
    TopicAndPartition tap = new TopicAndPartition(tp.topic(), tp.partition());
    List<Object> objs = Arrays.asList(entry.getValue()).stream()
        .map(val -> (Object) val).collect(Collectors.toList());
    Seq<Object> replicas = JavaConverters.asScalaBuffer(objs).seq();
    result.put(tap, replicas);
  }

  assert replicasMap.size() == result.size();
  LOG.debug("replicaMap.size = {}, result.size = {}", replicasMap.size(), result.size());
  return result;
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:19,代码来源:KafkaClusterManager.java

示例6: reassignPartitions

import scala.collection.Seq; //导入依赖的package包/类
private static void reassignPartitions(ZkUtils zkUtils, 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>> newAssignment =
      AdminUtils.assignReplicasToBrokers(brokersMetadata, partitionCount, replicationFactor, 0, 0);

  scala.collection.mutable.ArrayBuffer<String> topicList = new scala.collection.mutable.ArrayBuffer<>();
  topicList.$plus$eq(topic);
  scala.collection.Map<Object, scala.collection.Seq<Object>> currentAssignment = zkUtils.getPartitionAssignmentForTopics(topicList).apply(topic);
  String currentAssignmentJson = formatAsReassignmentJson(topic, currentAssignment);
  String newAssignmentJson = formatAsReassignmentJson(topic, newAssignment);

  LOG.info("Reassign partitions for topic " + topic);
  LOG.info("Current partition replica assignment " + currentAssignmentJson);
  LOG.info("New partition replica assignment " + newAssignmentJson);
  zkUtils.createPersistentPath(ZkUtils.ReassignPartitionsPath(), newAssignmentJson, zkUtils.DefaultAcls());
}
 
开发者ID:linkedin,项目名称:kafka-monitor,代码行数:20,代码来源:MultiClusterTopicManagementService.java

示例7: getPartitionInfo

import scala.collection.Seq; //导入依赖的package包/类
private static List<PartitionInfo> getPartitionInfo(ZkUtils zkUtils, String topic) {
  scala.collection.mutable.ArrayBuffer<String> topicList = new scala.collection.mutable.ArrayBuffer<>();
  topicList.$plus$eq(topic);
  scala.collection.Map<Object, scala.collection.Seq<Object>> partitionAssignments =
      zkUtils.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 = zkUtils.getLeaderForPartition(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;
}
 
开发者ID:linkedin,项目名称:kafka-monitor,代码行数:23,代码来源:MultiClusterTopicManagementService.java

示例8: formatAsReassignmentJson

import scala.collection.Seq; //导入依赖的package包/类
/**
 * @param topic topic
 * @param partitionsToBeReassigned a map from partition (int) to replica list (int seq)
 *
 * @return a json string with the same format as output of kafka.utils.ZkUtils.formatAsReassignmentJson
 *
 * Example:
 * <pre>
 *   {"version":1,"partitions":[
 *     {"topic":"kmf-topic","partition":1,"replicas":[0,1]},
 *     {"topic":"kmf-topic","partition":2,"replicas":[1,2]},
 *     {"topic":"kmf-topic","partition":0,"replicas":[2,0]}]}
 * </pre>
 */
private static String formatAsReassignmentJson(String topic, scala.collection.Map<Object, Seq<Object>> partitionsToBeReassigned) {
  StringBuilder bldr = new StringBuilder();
  bldr.append("{\"version\":1,\"partitions\":[\n");
  for (int partition = 0; partition < partitionsToBeReassigned.size(); partition++) {
    bldr.append("  {\"topic\":\"").append(topic).append("\",\"partition\":").append(partition).append(",\"replicas\":[");
    scala.collection.Seq<Object> replicas = partitionsToBeReassigned.apply(partition);
    for (int replicaIndex = 0; replicaIndex < replicas.size(); replicaIndex++) {
      Object replica = replicas.apply(replicaIndex);
      bldr.append(replica).append(",");
    }
    bldr.setLength(bldr.length() - 1);
    bldr.append("]},\n");
  }
  bldr.setLength(bldr.length() - 2);
  bldr.append("]}");
  return bldr.toString();
}
 
开发者ID:linkedin,项目名称:kafka-monitor,代码行数:32,代码来源:MultiClusterTopicManagementService.java

示例9: getGearpumpState

import scala.collection.Seq; //导入依赖的package包/类
private State getGearpumpState() {
  ApplicationStatus status = null;
  List<AppMasterData> apps =
      JavaConverters.<AppMasterData>seqAsJavaListConverter(
          (Seq<AppMasterData>) client.listApps().appMasters()).asJava();
  for (AppMasterData appData: apps) {
    if (appData.appId() == app.appId()) {
      status = appData.status();
    }
  }
  if (null == status || status instanceof ApplicationStatus.NONEXIST$) {
    return State.UNKNOWN;
  } else if (status instanceof ApplicationStatus.ACTIVE$) {
    return State.RUNNING;
  } else if (status instanceof ApplicationStatus.SUCCEEDED$) {
    return State.DONE;
  } else {
    return State.FAILED;
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:21,代码来源:GearpumpPipelineResult.java

示例10: getLeaderToShutDown

import scala.collection.Seq; //导入依赖的package包/类
@Override
public int getLeaderToShutDown(String topic) throws Exception {
	ZkUtils zkUtils = getZkUtils();
	try {
		PartitionMetadata firstPart = null;
		do {
			if (firstPart != null) {
				LOG.info("Unable to find leader. error code {}", firstPart.errorCode());
				// not the first try. Sleep a bit
				Thread.sleep(150);
			}

			Seq<PartitionMetadata> partitionMetadata = AdminUtils.fetchTopicMetadataFromZk(topic, zkUtils).partitionsMetadata();
			firstPart = partitionMetadata.head();
		}
		while (firstPart.errorCode() != 0);

		return firstPart.leader().get().id();
	} finally {
		zkUtils.close();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:KafkaTestEnvironmentImpl.java

示例11: testCassandraScalaTupleAtLeastOnceSinkBuilderDetection

import scala.collection.Seq; //导入依赖的package包/类
@Test
public void testCassandraScalaTupleAtLeastOnceSinkBuilderDetection() throws Exception {
	Class<scala.Tuple1<String>> c = (Class<scala.Tuple1<String>>) new scala.Tuple1<>("hello").getClass();
	Seq<TypeInformation<?>> typeInfos = JavaConverters.asScalaBufferConverter(
		Collections.<TypeInformation<?>>singletonList(BasicTypeInfo.STRING_TYPE_INFO)).asScala();
	Seq<String> fieldNames = JavaConverters.asScalaBufferConverter(
		Collections.singletonList("_1")).asScala();

	CaseClassTypeInfo<scala.Tuple1<String>> typeInfo = new CaseClassTypeInfo<scala.Tuple1<String>>(c, null, typeInfos, fieldNames) {
		@Override
		public TypeSerializer<scala.Tuple1<String>> createSerializer(ExecutionConfig config) {
			return null;
		}
	};

	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	DataStream<scala.Tuple1<String>> input = env.fromElements(new scala.Tuple1<>("hello")).returns(typeInfo);

	CassandraSink.CassandraSinkBuilder<scala.Tuple1<String>> sinkBuilder = CassandraSink.addSink(input);
	assertTrue(sinkBuilder instanceof CassandraSink.CassandraScalaProductSinkBuilder);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:CassandraConnectorITCase.java

示例12: getLeaderToShutDown

import scala.collection.Seq; //导入依赖的package包/类
@Override
public int getLeaderToShutDown(String topic) throws Exception {
	ZkClient zkClient = createZkClient();
	PartitionMetadata firstPart = null;
	do {
		if (firstPart != null) {
			LOG.info("Unable to find leader. error code {}", firstPart.errorCode());
			// not the first try. Sleep a bit
			Thread.sleep(150);
		}

		Seq<PartitionMetadata> partitionMetadata = AdminUtils.fetchTopicMetadataFromZk(topic, zkClient).partitionsMetadata();
		firstPart = partitionMetadata.head();
	}
	while (firstPart.errorCode() != 0);
	zkClient.close();

	return firstPart.leader().get().id();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:KafkaTestEnvironmentImpl.java

示例13: interpolate

import scala.collection.Seq; //导入依赖的package包/类
public ProverExpr[] interpolate(int[][] partitionSeq) {
	final ArrayBuffer<Set<Object>> args = new ArrayBuffer<Set<Object>>();
	for (int i = 0; i < partitionSeq.length; ++i) {
		final ArrayBuffer<Object> indexes = new ArrayBuffer<Object>();
		for (int j = 0; j < partitionSeq[i].length; ++j)
			indexes.$plus$eq(Integer.valueOf(partitionSeq[i][j]));
		args.$plus$eq(indexes.toSet());
	}

	final Seq<IFormula> ints = api.getInterpolants(args.toSeq(),1000000);

	final ProverExpr[] res = new ProverExpr[partitionSeq.length - 1];
	for (int i = 0; i < partitionSeq.length - 1; ++i)
		res[i] = new FormulaExpr(ints.apply(i));

	return res;
}
 
开发者ID:SRI-CSL,项目名称:bixie,代码行数:18,代码来源:PrincessProver.java

示例14: call

import scala.collection.Seq; //导入依赖的package包/类
public F.Promise<Result> call(Http.Context context) throws Throwable {

        User user = checkAuthentication(context);

        // Check if a user is logged in
        if (user != null) {
            // Check if user has an allowed role
            User.Role[] allowedRoles = configuration.value();
            for(User.Role role : allowedRoles)  {
                if (role.equals(user.getRole())) {
                    return delegate.call(context);
                }
            }
        }

        List<Tuple2<String, String>> list = new ArrayList<>();
        Tuple2<String, String> h = new Tuple2<>("Access-Control-Allow-Origin","*");
        list.add(h);
        Seq<Tuple2<String, String>> seq = Scala.toSeq(list);
        Result error = () -> Results.unauthorized().toScala().withHeaders(seq);
        return F.Promise.pure(error);
    }
 
开发者ID:ugent-cros,项目名称:cros-core,代码行数:23,代码来源:Authenticator.java

示例15: testExtractKeyFromRowForEntity

import scala.collection.Seq; //导入依赖的package包/类
@Test
public void testExtractKeyFromRowForEntity() throws Exception {
    final ExtractKeyFromRow entityConverter = new ExtractKeyFromRow(groupByColumns, columnsToPaths, true);
    final Row row = DataGen.generateEntityRow(utils, "BasicEntity", "vertex", (byte) 'a', 0.2, 3f, TestUtils.getTreeSet1(), 5L, (short) 6, TestUtils.DATE, TestUtils.getFreqMap1(), null);
    final Seq<Object> results = entityConverter.call(row);
    final List<Object> actual = new ArrayList<>(4);
    for (int i = 0; i < results.length(); i++) {
        actual.add(results.apply(i));
    }
    final List<Object> expected = new ArrayList<>(4);
    expected.add(0.2);
    expected.add("vertex");
    expected.add(TestUtils.DATE.getTime());
    expected.add(WrappedArray$.MODULE$.make(TestUtils.getTreeSet1().toArray()));
    assertThat(expected, containsInAnyOrder(actual.toArray()));
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:17,代码来源:ExtractKeyFromRowTest.java


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