zoukankan      html  css  js  c++  java
  • Operator_takeAndFirst

    package com.bjsxt.spark.actions;

    import java.util.Arrays;
    import java.util.List;

    import org.apache.spark.SparkConf;
    import org.apache.spark.api.java.JavaRDD;
    import org.apache.spark.api.java.JavaSparkContext;
    /**
    * take
    *
    * @author root
    *
    */
    public class Operator_takeAndFirst {
    public static void main(String[] args) {
    SparkConf conf = new SparkConf();
    conf.setMaster("local").setAppName("take");
    JavaSparkContext jsc = new JavaSparkContext(conf);
    JavaRDD<Tuple2<Integer,String>> parallelize = jsc.parallelize(
    Arrays.asList(
    new Tuple2<Integer,String>(1,"a"),
    new Tuple2<Integer,String>(2,"b"),
    new Tuple2<Integer,String>(3,"c"),
    new Tuple2<Integer,String>(4,"d")
    )
    );
    List<Tuple2<Integer,String>> take = parallelize.take(2);
    for(Tuple2<Integer,String> s:take){
    System.out.println(s);
    }
    jsc.stop();
    */

    JavaRDD<String> parallelize = jsc.parallelize(Arrays.asList("a","b","c","d"));
    List<String> take = parallelize.take(2);
    String first = parallelize.first();
    for(String s:take){
    System.out.println(s);
    }
    jsc.stop();
    }
    }

  • 相关阅读:
    Flask发送邮件
    python 可调用对象之类实例
    flask 跨域请求
    flask登录插件 flask-login
    flask 更新数据库
    python事物管理及同步锁
    Django signals 信号作用及用法说明
    python中各个response使用
    Ntp时间服务器
    Iptables-主机防火墙设置
  • 原文地址:https://www.cnblogs.com/huiandong/p/9194566.html
Copyright © 2011-2022 走看看