package com.bjsxt;
import java.util.List;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.api.java.function.VoidFunction;
public class Scala {
public static void main(String[] args) {
/**
* 配置
*/
SparkConf conf = new SparkConf().setMaster("local").setAppName("test");
/**
* context上下文
*/
JavaSparkContext sc = new JavaSparkContext(conf);
/**
* sc.textFile()
* 用于传入上下文
*/
JavaRDD<String> line = sc.textFile("./words");
/**
* filter算子
*/
JavaRDD<String> filter = line.filter(new Function<String, Boolean>() {
@Override
public Boolean
Java版算子汇总(包括filter,collect,take,first,sample等)【Java纯代码】
最新推荐文章于 2022-08-18 17:51:16 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)