-
Notifications
You must be signed in to change notification settings - Fork 70
/
Combiner.java
executable file
·39 lines (33 loc) · 1.41 KB
/
Combiner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* @file
*****************************************************************************
* @author This file is part of zkspark, developed by SCIPR Lab
* and contributors (see AUTHORS).
* @copyright MIT license (see LICENSE file)
*****************************************************************************/
package common;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.api.java.function.Function2;
import scala.Tuple2;
import java.util.ArrayList;
/**
* Combiner implements a set of three functions used by JavaPairRDD.combineByKey() to partition
* elements into the specified organization.
*/
public class Combiner<T> {
// The following functions are used for combineByKey() in FFTAuxiliary, NaiveEvaluation, and BACE.
public final Function<Tuple2<Long, T>, ArrayList<Tuple2<Long, T>>> createGroup = element -> {
final ArrayList<Tuple2<Long, T>> a = new ArrayList<>();
a.add(element);
return a;
};
public final Function2<ArrayList<Tuple2<Long, T>>, Tuple2<Long, T>, ArrayList<Tuple2<Long, T>>>
mergeElement = (element1, element2) -> {
element1.add(element2);
return element1;
};
public final Function2<ArrayList<Tuple2<Long, T>>, ArrayList<Tuple2<Long, T>>,
ArrayList<Tuple2<Long, T>>> mergeCombiner = (element1, element2) -> {
element1.addAll(element2);
return element1;
};
}