@@ -0,0 +1,1164 @@
+package net.jgp.labs.spark.l300_reduce.l000;%0A%0Aimport java.io.Serializable;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.apache.spark.api.java.function.ReduceFunction;%0Aimport org.apache.spark.sql.Dataset;%0Aimport org.apache.spark.sql.Encoders;%0Aimport org.apache.spark.sql.SparkSession;%0A%0Apublic class ReducerApp implements Serializable %7B%0A%09private static final long serialVersionUID = -8951059218545451099L;%0A%0A%09private final class SumByReduce implements ReduceFunction%3CInteger%3E %7B%0A%09%09private static final long serialVersionUID = -7580381094052442862L;%0A%0A%09%09@Override%0A%09%09public Integer call(Integer v1, Integer v2) throws Exception %7B%0A%09%09%09return v1 + v2;%0A%09%09%7D%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09ReducerApp ra = new ReducerApp();%0A%09%09ra.start();%0A%09%7D%0A%0A%09private void start() %7B%09%09%0A%09%09SparkSession spark = SparkSession.builder().master(%22local%22).getOrCreate();%0A%0A%09%09List%3CInteger%3E data = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);%0A%09%09Dataset%3CInteger%3E df = spark.createDataset(data, Encoders.INT());%0A%09%09df.show();%0A%09%09df.printSchema();%0A%09%09Integer sumByReduce = df.reduce(new SumByReduce());%0A%09%09System.out.println(%22Sum should be 55 and it is... %22 + sumByReduce);%0A%09%7D%0A%0A%7D%0A

Work on simple reducer for Dataframe