1818
1919package org .apache .wayang .core .function ;
2020
21+ import java .util .function .BinaryOperator ;
22+
2123import org .apache .wayang .core .optimizer .costs .LoadEstimator ;
2224import org .apache .wayang .core .optimizer .costs .LoadProfileEstimator ;
2325import org .apache .wayang .core .optimizer .costs .NestableLoadProfileEstimator ;
2426import org .apache .wayang .core .types .BasicDataUnitType ;
2527import org .apache .wayang .core .types .DataUnitGroupType ;
2628import org .apache .wayang .core .types .DataUnitType ;
2729
28- import java .util .function .BinaryOperator ;
29-
3030/**
31- * This descriptor pertains to functions that take multiple data units and aggregate them into a single data unit
32- * by means of a tree-like fold, i.e., using a commutative, associative function..
31+ * This descriptor pertains to functions that take multiple data units and
32+ * aggregate them into a single data unit by means of a tree-like fold, i.e.,
33+ * using a commutative, associative function..
3334 */
3435public class ReduceDescriptor <Type > extends FunctionDescriptor {
3536
@@ -39,43 +40,67 @@ public class ReduceDescriptor<Type> extends FunctionDescriptor {
3940
4041 private final SerializableBinaryOperator <Type > javaImplementation ;
4142
42- public ReduceDescriptor (SerializableBinaryOperator <Type > javaImplementation ,
43- DataUnitGroupType <Type > inputType ,
44- BasicDataUnitType <Type > outputType ) {
43+ /**
44+ * sql implementation of the reduce operator
45+ */
46+ private String sqlImplementation ;
47+
48+ public ReduceDescriptor (final SerializableBinaryOperator <Type > javaImplementation , final DataUnitGroupType <Type > inputType ,
49+ final BasicDataUnitType <Type > outputType ) {
4550 this (javaImplementation , inputType , outputType , new NestableLoadProfileEstimator (
46- LoadEstimator .createFallback (1 , 1 ),
47- LoadEstimator .createFallback (1 , 1 )
48- ));
51+ LoadEstimator .createFallback (1 , 1 ), LoadEstimator .createFallback (1 , 1 )));
4952 }
5053
51- public ReduceDescriptor (SerializableBinaryOperator <Type > javaImplementation ,
52- DataUnitGroupType <Type > inputType , BasicDataUnitType <Type > outputType ,
53- LoadProfileEstimator loadProfileEstimator ) {
54+ public ReduceDescriptor (final SerializableBinaryOperator <Type > javaImplementation , final DataUnitGroupType <Type > inputType ,
55+ final BasicDataUnitType <Type > outputType , final LoadProfileEstimator loadProfileEstimator ) {
5456 super (loadProfileEstimator );
5557 this .inputType = inputType ;
5658 this .outputType = outputType ;
5759 this .javaImplementation = javaImplementation ;
5860 }
5961
60- public ReduceDescriptor (SerializableBinaryOperator <Type > javaImplementation , Class <Type > inputType ) {
62+ public ReduceDescriptor (final SerializableBinaryOperator <Type > javaImplementation , final Class <Type > inputType ) {
6163 this (javaImplementation , DataUnitType .createGroupedUnchecked (inputType ),
62- DataUnitType .createBasicUnchecked (inputType )
63- );
64+ DataUnitType .createBasicUnchecked (inputType ));
6465 }
6566
67+ /**
68+ * This is function is not built to last. It is thought to help out devising
69+ * programs while we are still figuring
70+ * out how to express functions in a platform-independent way.
71+ *
72+ * @return a function that can perform the reduce
73+ */
74+ public String getSqlImplementation () {
75+ return this .sqlImplementation ;
76+ }
6677
6778 /**
68- * This is function is not built to last. It is thought to help out devising programs while we are still figuring
79+ * This is function is not built to last. It is thought to help out devising
80+ * programs while we are still figuring
6981 * out how to express functions in a platform-independent way.
7082 *
7183 * @return a function that can perform the reduce
7284 */
85+ public ReduceDescriptor <Type > withSqlImplementation (final String sqlImplementation ) {
86+ this .sqlImplementation = sqlImplementation ;
87+ return this ;
88+ }
89+
90+ /**
91+ * This is function is not built to last. It is thought to help out devising
92+ * programs while we are still figuring out how to express functions in a
93+ * platform-independent way.
94+ *
95+ * @return a function that can perform the reduce
96+ */
7397 public BinaryOperator <Type > getJavaImplementation () {
7498 return this .javaImplementation ;
7599 }
76100
77101 /**
78- * In generic code, we do not have the type parameter values of operators, functions etc. This method avoids casting issues.
102+ * In generic code, we do not have the type parameter values of operators,
103+ * functions etc. This method avoids casting issues.
79104 *
80105 * @return this instance with type parameters set to {@link Object}
81106 */
0 commit comments