scala.collection.Seq.head()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(177)

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

Seq.head介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

/**
   * Util method that checks that output schema contains only double types and returns list of field names.
   *
   * @param mdl Pipeline model.
   * @return List of field names.
   */
  private List<String> checkAndGetInputSchema(PipelineModel mdl) {
    Transformer firstTransformer = mdl.transformers().head();
    StructType inputSchema = firstTransformer.inputSchema();

    List<StructField> input = new ArrayList<>(JavaConverters.seqAsJavaListConverter(inputSchema.fields()).asJava());

    List<String> schema = new ArrayList<>();

    for (StructField field : input) {
      String fieldName = field.name();

      schema.add(field.name());
      if (!ScalarType.Double().base().equals(field.dataType().base()))
        throw new IllegalArgumentException("Parser supports only double types [name=" +
          fieldName + ",type=" + field.dataType() + "]");
    }

    return schema;
  }
}

代码示例来源:origin: apache/flink

@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();
  }
}

代码示例来源:origin: allegro/hermes

private void cleanLogs()  {
  try {
    FileUtils.deleteDirectory(new File(kafkaConfig.logDirs().head()));
  } catch (IOException e) {
    logger.info("Error while removing kafka logs", e);
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-test-helper

private void cleanLogs()  {
  try {
    FileUtils.deleteDirectory(new File(kafkaConfig.logDirs().head()));
  } catch (IOException e) {
    logger.info("Error while removing kafka logs", e);
    throw new IllegalStateException(e);
  }
}

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

ul.childSort = ((NonTerminal) p.items().head()).sort();
  ul.pList = p;
} else if (p.items().size() == 1 && p.items().head() instanceof Terminal) {
  ul.terminatorKLabel = p.klabel().get();
  ul.pTerminator = p;

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

ul.childSort = ((NonTerminal) p.items().head()).sort();
  ul.pList = p;
} else if (p.items().size() == 1 && p.items().head() instanceof Terminal) {
  ul.terminatorKLabel = p.klabel().get().name();
  ul.pTerminator = p;

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

private static void checkCircularModuleImports(Module mainModule, scala.collection.Seq<Module> visitedModules) {
  if (visitedModules.contains(mainModule)) {
    String msg = "Found circularity in module imports: ";
    for (Module m : mutable(visitedModules)) { // JavaConversions.seqAsJavaList(visitedModules)
      msg += m.getName() + " < ";
    }
    msg += visitedModules.head().getName();
    throw KEMException.compilerError(msg);
  }
}

代码示例来源: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: org.apache.flink/flink-connector-kafka-0.9_2.11

@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();
  }
}

代码示例来源:origin: com.alibaba.blink/flink-connector-kafka-0.9

@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();
  }
}

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

Production p = (Production) s;
assert p.items().head() instanceof Terminal || p.items().head() instanceof RegexTerminal;
assert p.items().last() instanceof Terminal || p.items().last() instanceof RegexTerminal;
final ProductionItem body;
Seq<ProductionItem> pi = Seq(p.items().head(), optDots, body, optDots, p.items().last());
Production p1 = Production(p.klabel().get(), p.sort(), pi, p.att());
Production p2 = Production(Sorts.Cell(), Seq(NonTerminal(p.sort())));

相关文章