aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorWenchen Fan <wenchen@databricks.com>2015-11-09 15:16:47 -0800
committerMichael Armbrust <michael@databricks.com>2015-11-09 15:16:47 -0800
commitfcb57e9c7323e24b8563800deb035f94f616474e (patch)
tree5c368aa1f2feb5bf5a573c4397637d588046f1b9 /core
parent8a2336893a7ff610a6c4629dd567b85078730616 (diff)
downloadspark-fcb57e9c7323e24b8563800deb035f94f616474e.tar.gz
spark-fcb57e9c7323e24b8563800deb035f94f616474e.tar.bz2
spark-fcb57e9c7323e24b8563800deb035f94f616474e.zip
[SPARK-11564][SQL][FOLLOW-UP] improve java api for GroupedDataset
created `MapGroupFunction`, `FlatMapGroupFunction`, `CoGroupFunction` Author: Wenchen Fan <wenchen@databricks.com> Closes #9564 from cloud-fan/map.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/org/apache/spark/api/java/function/CoGroupFunction.java29
-rw-r--r--core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction.java2
-rw-r--r--core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction2.java2
-rw-r--r--core/src/main/java/org/apache/spark/api/java/function/FlatMapGroupFunction.java28
-rw-r--r--core/src/main/java/org/apache/spark/api/java/function/MapGroupFunction.java28
5 files changed, 87 insertions, 2 deletions
diff --git a/core/src/main/java/org/apache/spark/api/java/function/CoGroupFunction.java b/core/src/main/java/org/apache/spark/api/java/function/CoGroupFunction.java
new file mode 100644
index 0000000000..279639af5d
--- /dev/null
+++ b/core/src/main/java/org/apache/spark/api/java/function/CoGroupFunction.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.api.java.function;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * A function that returns zero or more output records from each grouping key and its values from 2
+ * Datasets.
+ */
+public interface CoGroupFunction<K, V1, V2, R> extends Serializable {
+ Iterable<R> call(K key, Iterator<V1> left, Iterator<V2> right) throws Exception;
+}
diff --git a/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction.java b/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction.java
index 23f5fdd436..ef0d182412 100644
--- a/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction.java
+++ b/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction.java
@@ -23,5 +23,5 @@ import java.io.Serializable;
* A function that returns zero or more output records from each input record.
*/
public interface FlatMapFunction<T, R> extends Serializable {
- public Iterable<R> call(T t) throws Exception;
+ Iterable<R> call(T t) throws Exception;
}
diff --git a/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction2.java b/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction2.java
index c48e92f535..14a98a38ef 100644
--- a/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction2.java
+++ b/core/src/main/java/org/apache/spark/api/java/function/FlatMapFunction2.java
@@ -23,5 +23,5 @@ import java.io.Serializable;
* A function that takes two inputs and returns zero or more output records.
*/
public interface FlatMapFunction2<T1, T2, R> extends Serializable {
- public Iterable<R> call(T1 t1, T2 t2) throws Exception;
+ Iterable<R> call(T1 t1, T2 t2) throws Exception;
}
diff --git a/core/src/main/java/org/apache/spark/api/java/function/FlatMapGroupFunction.java b/core/src/main/java/org/apache/spark/api/java/function/FlatMapGroupFunction.java
new file mode 100644
index 0000000000..18a2d733ca
--- /dev/null
+++ b/core/src/main/java/org/apache/spark/api/java/function/FlatMapGroupFunction.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.api.java.function;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * A function that returns zero or more output records from each grouping key and its values.
+ */
+public interface FlatMapGroupFunction<K, V, R> extends Serializable {
+ Iterable<R> call(K key, Iterator<V> values) throws Exception;
+}
diff --git a/core/src/main/java/org/apache/spark/api/java/function/MapGroupFunction.java b/core/src/main/java/org/apache/spark/api/java/function/MapGroupFunction.java
new file mode 100644
index 0000000000..2935f9986a
--- /dev/null
+++ b/core/src/main/java/org/apache/spark/api/java/function/MapGroupFunction.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.api.java.function;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * Base interface for a map function used in GroupedDataset's map function.
+ */
+public interface MapGroupFunction<K, V, R> extends Serializable {
+ R call(K key, Iterator<V> values) throws Exception;
+}