You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/10/09 16:49:22 UTC
[GitHub] [hudi] wangxianghu opened a new pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
wangxianghu opened a new pull request #2161:
URL: https://github.com/apache/hudi/pull/2161
## *Tips*
- *Thank you very much for contributing to Apache Hudi.*
- *Please review https://hudi.apache.org/contributing.html before opening a pull request.*
## What is the purpose of the pull request
*Introduce HoodieFlinkEngineContext to hudi-flink-client*
## Brief change log
*(for example:)*
- *Modify AnnotationLocation checkstyle rule in checkstyle.xml*
## Verify this pull request
This pull request is already covered by existing tests, such as *TestHoodieFlinkEngineContext*.
## Committer checklist
- [ ] Has a corresponding JIRA in PR title & commit
- [ ] Commit message is descriptive of the change
- [ ] CI is green
- [ ] Necessary doc changes done or have another open PR
- [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] wangxianghu commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
wangxianghu commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502729962
##########
File path: hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/common/HoodieFlinkEngineContext.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.hudi.client.common;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hudi.client.common.function.SerializableConsumer;
+import org.apache.hudi.client.common.function.SerializableFunction;
+import org.apache.hudi.client.common.function.SerializablePairFunction;
+import org.apache.hudi.common.config.SerializableConfiguration;
+import org.apache.hudi.common.util.Option;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingFlatMapWrapper;
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingForeachWrapper;
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingMapToPairWrapper;
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingMapWrapper;
+
+/**
+ * A flink engine implementation of HoodieEngineContext.
+ */
+public class HoodieFlinkEngineContext extends HoodieEngineContext {
+
+ public HoodieFlinkEngineContext(TaskContextSupplier taskContextSupplier) {
+ this(new SerializableConfiguration(new Configuration()), taskContextSupplier);
+ }
+
+ public HoodieFlinkEngineContext(SerializableConfiguration hadoopConf, TaskContextSupplier taskContextSupplier) {
+ super(hadoopConf, taskContextSupplier);
+ }
+
+ @Override
+ public <I, O> List<O> map(List<I> data, SerializableFunction<I, O> func, int parallelism) {
+ return data.stream().parallel().map(throwingMapWrapper(func)).collect(Collectors.toList());
+ }
+
+ @Override
+ public <I, O> List<O> flatMap(List<I> data, SerializableFunction<I, Stream<O>> func, int parallelism) {
+ return data.stream().parallel().flatMap(throwingFlatMapWrapper(func)).collect(Collectors.toList());
+ }
+
+ @Override
+ public <I> void foreach(List<I> data, SerializableConsumer<I> consumer, int parallelism) {
+ data.forEach(throwingForeachWrapper(consumer));
+ }
+
+ @Override
+ public <I, K, V> Map<K, V> mapToPair(List<I> data, SerializablePairFunction<I, K, V> func, Integer parallelism) {
+ Map<K, V> map = new HashMap<>();
+ data.stream().map(throwingMapToPairWrapper(func)).forEach(x -> map.put(x._1, x._2));
+ return map;
+ }
+
+ @Override
+ public void setProperty(EngineProperty key, String value) {
+ // no operation for now
+ }
+
+ @Override
+ public Option<String> getProperty(EngineProperty key) {
+ // no operation for now
+ return Option.empty();
+ }
+
+ @Override
+ public void setJobStatus(String activeModule, String activityDescription) {
+ // no operation for now
+ }
Review comment:
> maybe we would move the methods to super class as default implementation after finishing the flink integration.
Good idea
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] wangxianghu commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
wangxianghu commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502731487
##########
File path: hudi-client/hudi-flink-client/src/test/java/org/apache/hudi/client/common/TestHoodieFlinkEngineContext.java
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.hudi.client.common;
+
+import org.apache.hudi.common.util.Option;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scala.Tuple2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * Unit test against HoodieFlinkEngineContext.
+ */
+public class TestHoodieFlinkEngineContext {
+ private HoodieFlinkEngineContext context;
+
+ @BeforeEach
+ public void init() {
+ context = new HoodieFlinkEngineContext(new DummyTaskContextSupplier());
+ }
+
+ @Test
+ public void testMap() {
+ List<Integer> mapList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ List<Integer> result = context.map(mapList, x -> x + 1, 2);
+ result.removeAll(mapList);
+
+ Assertions.assertEquals(1, result.size());
+ Assertions.assertEquals(11, result.get(0));
+ }
+
+ @Test
+ public void testFlatMap() {
+ List<String> list1 = Arrays.asList("a", "b", "c");
+ List<String> list2 = Arrays.asList("d", "e", "f");
+ List<String> list3 = Arrays.asList("g", "h", "i");
+
+ List<List<String>> inputList = new ArrayList<>();
+ inputList.add(list1);
+ inputList.add(list2);
+ inputList.add(list3);
+
+ List<String> result = context.flatMap(inputList, Collection::stream, 2);
+
+ Assertions.assertEquals(9, result.size());
+ }
+
+ @Test
+ public void testForeach() {
+ List<Integer> mapList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ List<Integer> result = new ArrayList<>(10);
+ context.foreach(mapList, result::add, 2);
+
+ Assertions.assertEquals(result.size(), mapList.size());
+ Assertions.assertTrue(result.containsAll(mapList));
+ }
+
+ @Test
+ public void testMapToPair() {
+ List<String> mapList = Arrays.asList("hudi_flink", "hudi_spark");
+
+ Map<String, String> resultMap = context.mapToPair(mapList, x -> {
+ String[] splits = x.split("_");
+ return Tuple2.apply(splits[0], splits[1]);
+ }, 2);
+
+ Assertions.assertEquals("spark", resultMap.get("hudi"));
Review comment:
> here would always get `spark` instead of `flink`?
It should be. List is ordered.
But `Assertions.assertNotNull(resultMap.get("hudi"))` should be better understood
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] wangxianghu commented on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
wangxianghu commented on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-706289720
@yanghua @leesf please take a look when free
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] wangxianghu commented on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
wangxianghu commented on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-707549668
> I am okay with the PR as-is. IIUC this change does not really add any flink related changes. It might be good to have PRs, such that add some functionality in each PR.
>
> Also +1 on deferring further refactoring/reorganization until we can implement a first cut of flink support.
Yes, this PR actually aims to introduce `hudi-flink-client`module, which is the basis of the incoming functionality PRs.
Agree with you that each PR should contain some functionality, will push it as your suggest
thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] vinothchandar commented on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
vinothchandar commented on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-707551778
sg! @wangxianghu
I ll let @leesf or @yanghua do the merging once they are ready
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] leesf commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502729805
##########
File path: hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/common/HoodieFlinkEngineContext.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.hudi.client.common;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hudi.client.common.function.SerializableConsumer;
+import org.apache.hudi.client.common.function.SerializableFunction;
+import org.apache.hudi.client.common.function.SerializablePairFunction;
+import org.apache.hudi.common.config.SerializableConfiguration;
+import org.apache.hudi.common.util.Option;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingFlatMapWrapper;
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingForeachWrapper;
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingMapToPairWrapper;
+import static org.apache.hudi.client.common.function.FunctionWrapper.throwingMapWrapper;
+
+/**
+ * A flink engine implementation of HoodieEngineContext.
+ */
+public class HoodieFlinkEngineContext extends HoodieEngineContext {
+
+ public HoodieFlinkEngineContext(TaskContextSupplier taskContextSupplier) {
+ this(new SerializableConfiguration(new Configuration()), taskContextSupplier);
+ }
+
+ public HoodieFlinkEngineContext(SerializableConfiguration hadoopConf, TaskContextSupplier taskContextSupplier) {
+ super(hadoopConf, taskContextSupplier);
+ }
+
+ @Override
+ public <I, O> List<O> map(List<I> data, SerializableFunction<I, O> func, int parallelism) {
+ return data.stream().parallel().map(throwingMapWrapper(func)).collect(Collectors.toList());
+ }
+
+ @Override
+ public <I, O> List<O> flatMap(List<I> data, SerializableFunction<I, Stream<O>> func, int parallelism) {
+ return data.stream().parallel().flatMap(throwingFlatMapWrapper(func)).collect(Collectors.toList());
+ }
+
+ @Override
+ public <I> void foreach(List<I> data, SerializableConsumer<I> consumer, int parallelism) {
+ data.forEach(throwingForeachWrapper(consumer));
+ }
+
+ @Override
+ public <I, K, V> Map<K, V> mapToPair(List<I> data, SerializablePairFunction<I, K, V> func, Integer parallelism) {
+ Map<K, V> map = new HashMap<>();
+ data.stream().map(throwingMapToPairWrapper(func)).forEach(x -> map.put(x._1, x._2));
+ return map;
+ }
+
+ @Override
+ public void setProperty(EngineProperty key, String value) {
+ // no operation for now
+ }
+
+ @Override
+ public Option<String> getProperty(EngineProperty key) {
+ // no operation for now
+ return Option.empty();
+ }
+
+ @Override
+ public void setJobStatus(String activeModule, String activityDescription) {
+ // no operation for now
+ }
Review comment:
maybe we would move the methods to super class as default implementation after finishing the flink integration.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io edited a comment on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-706340613
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=h1) Report
> Merging [#2161](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/1d1d91d444b6af2b24b17d94068512a930877a98?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2161 +/- ##
=========================================
Coverage 53.61% 53.61%
Complexity 2845 2845
=========================================
Files 359 359
Lines 16535 16535
Branches 1777 1777
=========================================
Hits 8866 8866
Misses 6912 6912
Partials 757 757
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| #hudicli | `38.37% <ø> (ø)` | `193.00 <ø> (ø)` | |
| #hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| #hudicommon | `54.74% <ø> (ø)` | `1793.00 <ø> (ø)` | |
| #hudihadoopmr | `33.05% <ø> (ø)` | `181.00 <ø> (ø)` | |
| #hudispark | `65.51% <ø> (ø)` | `303.00 <ø> (ø)` | |
| #huditimelineservice | `62.29% <ø> (ø)` | `50.00 <ø> (ø)` | |
| #hudiutilities | `69.98% <ø> (ø)` | `325.00 <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [.../org/apache/hudi/common/model/HoodieTableType.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL0hvb2RpZVRhYmxlVHlwZS5qYXZh) | `100.00% <0.00%> (ø)` | `1.00% <0.00%> (ø%)` | |
| [...i/common/model/OverwriteWithLatestAvroPayload.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL092ZXJ3cml0ZVdpdGhMYXRlc3RBdnJvUGF5bG9hZC5qYXZh) | `64.70% <0.00%> (ø)` | `10.00% <0.00%> (ø%)` | |
| [...del/OverwriteNonDefaultsWithLatestAvroPayload.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL092ZXJ3cml0ZU5vbkRlZmF1bHRzV2l0aExhdGVzdEF2cm9QYXlsb2FkLmphdmE=) | `78.94% <0.00%> (ø)` | `5.00% <0.00%> (ø%)` | |
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io edited a comment on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-706340613
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=h1) Report
> Merging [#2161](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/1d1d91d444b6af2b24b17d94068512a930877a98?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2161 +/- ##
=========================================
Coverage 53.61% 53.61%
Complexity 2845 2845
=========================================
Files 359 359
Lines 16535 16535
Branches 1777 1777
=========================================
Hits 8866 8866
Misses 6912 6912
Partials 757 757
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| #hudicli | `38.37% <ø> (ø)` | `193.00 <ø> (ø)` | |
| #hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| #hudicommon | `54.74% <ø> (ø)` | `1793.00 <ø> (ø)` | |
| #hudihadoopmr | `33.05% <ø> (ø)` | `181.00 <ø> (ø)` | |
| #hudispark | `65.51% <ø> (ø)` | `303.00 <ø> (ø)` | |
| #huditimelineservice | `62.29% <ø> (ø)` | `50.00 <ø> (ø)` | |
| #hudiutilities | `69.98% <ø> (ø)` | `325.00 <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [.../org/apache/hudi/common/model/HoodieTableType.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL0hvb2RpZVRhYmxlVHlwZS5qYXZh) | `100.00% <0.00%> (ø)` | `1.00% <0.00%> (ø%)` | |
| [...i/common/model/OverwriteWithLatestAvroPayload.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL092ZXJ3cml0ZVdpdGhMYXRlc3RBdnJvUGF5bG9hZC5qYXZh) | `64.70% <0.00%> (ø)` | `10.00% <0.00%> (ø%)` | |
| [...del/OverwriteNonDefaultsWithLatestAvroPayload.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL092ZXJ3cml0ZU5vbkRlZmF1bHRzV2l0aExhdGVzdEF2cm9QYXlsb2FkLmphdmE=) | `78.94% <0.00%> (ø)` | `5.00% <0.00%> (ø%)` | |
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] leesf commented on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
leesf commented on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-708099080
> sg! @wangxianghu
>
> I ll let @leesf or @yanghua do the merging once they are ready
Merging this PR. cc @vinothchandar
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] leesf commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502730336
##########
File path: hudi-client/hudi-flink-client/src/test/java/org/apache/hudi/client/common/TestHoodieFlinkEngineContext.java
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.hudi.client.common;
+
+import org.apache.hudi.common.util.Option;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scala.Tuple2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * Unit test against HoodieFlinkEngineContext.
+ */
+public class TestHoodieFlinkEngineContext {
+ private HoodieFlinkEngineContext context;
+
+ @BeforeEach
+ public void init() {
+ context = new HoodieFlinkEngineContext(new DummyTaskContextSupplier());
+ }
+
+ @Test
+ public void testMap() {
+ List<Integer> mapList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ List<Integer> result = context.map(mapList, x -> x + 1, 2);
+ result.removeAll(mapList);
+
+ Assertions.assertEquals(1, result.size());
+ Assertions.assertEquals(11, result.get(0));
+ }
+
+ @Test
+ public void testFlatMap() {
+ List<String> list1 = Arrays.asList("a", "b", "c");
+ List<String> list2 = Arrays.asList("d", "e", "f");
+ List<String> list3 = Arrays.asList("g", "h", "i");
+
+ List<List<String>> inputList = new ArrayList<>();
+ inputList.add(list1);
+ inputList.add(list2);
+ inputList.add(list3);
+
+ List<String> result = context.flatMap(inputList, Collection::stream, 2);
+
+ Assertions.assertEquals(9, result.size());
+ }
+
+ @Test
+ public void testForeach() {
+ List<Integer> mapList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ List<Integer> result = new ArrayList<>(10);
+ context.foreach(mapList, result::add, 2);
+
+ Assertions.assertEquals(result.size(), mapList.size());
+ Assertions.assertTrue(result.containsAll(mapList));
+ }
+
+ @Test
+ public void testMapToPair() {
+ List<String> mapList = Arrays.asList("hudi_flink", "hudi_spark");
+
+ Map<String, String> resultMap = context.mapToPair(mapList, x -> {
+ String[] splits = x.split("_");
+ return Tuple2.apply(splits[0], splits[1]);
+ }, 2);
+
+ Assertions.assertEquals("spark", resultMap.get("hudi"));
Review comment:
here would always get `spark` instead of `flink`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] wangxianghu commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
wangxianghu commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502731712
##########
File path: hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/common/function/FunctionWrapper.java
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.hudi.client.common.function;
+
+import scala.Tuple2;
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+/**
+ * Function wrapper util class, which catches the exception thrown by input function and return a similar function
+ * with no exception thrown.
+ */
+public class FunctionWrapper {
+
+ public static <I, O> Function<I, O> throwingMapWrapper(SerializableFunction<I, O> throwingMapFunction) {
+ return v1 -> {
+ try {
+ return throwingMapFunction.apply(v1);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
Review comment:
> use HoodieException?
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io commented on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-706340613
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=h1) Report
> Merging [#2161](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/1d1d91d444b6af2b24b17d94068512a930877a98?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2161 +/- ##
=========================================
Coverage 53.61% 53.61%
Complexity 2845 2845
=========================================
Files 359 359
Lines 16535 16535
Branches 1777 1777
=========================================
Hits 8866 8866
Misses 6912 6912
Partials 757 757
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| #hudicli | `38.37% <ø> (ø)` | `193.00 <ø> (ø)` | |
| #hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| #hudicommon | `54.74% <ø> (ø)` | `1793.00 <ø> (ø)` | |
| #hudihadoopmr | `33.05% <ø> (ø)` | `181.00 <ø> (ø)` | |
| #hudispark | `65.51% <ø> (ø)` | `303.00 <ø> (ø)` | |
| #huditimelineservice | `62.29% <ø> (ø)` | `50.00 <ø> (ø)` | |
| #hudiutilities | `69.98% <ø> (ø)` | `325.00 <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] leesf merged pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
leesf merged pull request #2161:
URL: https://github.com/apache/hudi/pull/2161
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] wangxianghu commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
wangxianghu commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502731487
##########
File path: hudi-client/hudi-flink-client/src/test/java/org/apache/hudi/client/common/TestHoodieFlinkEngineContext.java
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.hudi.client.common;
+
+import org.apache.hudi.common.util.Option;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scala.Tuple2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * Unit test against HoodieFlinkEngineContext.
+ */
+public class TestHoodieFlinkEngineContext {
+ private HoodieFlinkEngineContext context;
+
+ @BeforeEach
+ public void init() {
+ context = new HoodieFlinkEngineContext(new DummyTaskContextSupplier());
+ }
+
+ @Test
+ public void testMap() {
+ List<Integer> mapList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ List<Integer> result = context.map(mapList, x -> x + 1, 2);
+ result.removeAll(mapList);
+
+ Assertions.assertEquals(1, result.size());
+ Assertions.assertEquals(11, result.get(0));
+ }
+
+ @Test
+ public void testFlatMap() {
+ List<String> list1 = Arrays.asList("a", "b", "c");
+ List<String> list2 = Arrays.asList("d", "e", "f");
+ List<String> list3 = Arrays.asList("g", "h", "i");
+
+ List<List<String>> inputList = new ArrayList<>();
+ inputList.add(list1);
+ inputList.add(list2);
+ inputList.add(list3);
+
+ List<String> result = context.flatMap(inputList, Collection::stream, 2);
+
+ Assertions.assertEquals(9, result.size());
+ }
+
+ @Test
+ public void testForeach() {
+ List<Integer> mapList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ List<Integer> result = new ArrayList<>(10);
+ context.foreach(mapList, result::add, 2);
+
+ Assertions.assertEquals(result.size(), mapList.size());
+ Assertions.assertTrue(result.containsAll(mapList));
+ }
+
+ @Test
+ public void testMapToPair() {
+ List<String> mapList = Arrays.asList("hudi_flink", "hudi_spark");
+
+ Map<String, String> resultMap = context.mapToPair(mapList, x -> {
+ String[] splits = x.split("_");
+ return Tuple2.apply(splits[0], splits[1]);
+ }, 2);
+
+ Assertions.assertEquals("spark", resultMap.get("hudi"));
Review comment:
> here would always get `spark` instead of `flink`?
It should be. List is ordered.
`Assertions.assertNotNull(resultMap.get("hudi"))` should be better understood
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io edited a comment on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-706340613
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=h1) Report
> Merging [#2161](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/1d1d91d444b6af2b24b17d94068512a930877a98?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2161 +/- ##
=========================================
Coverage 53.61% 53.61%
Complexity 2845 2845
=========================================
Files 359 359
Lines 16535 16535
Branches 1777 1777
=========================================
Hits 8866 8866
Misses 6912 6912
Partials 757 757
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| #hudicli | `38.37% <ø> (ø)` | `193.00 <ø> (ø)` | |
| #hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| #hudicommon | `54.74% <ø> (ø)` | `1793.00 <ø> (ø)` | |
| #hudihadoopmr | `33.05% <ø> (ø)` | `181.00 <ø> (ø)` | |
| #hudispark | `65.51% <ø> (ø)` | `303.00 <ø> (ø)` | |
| #huditimelineservice | `62.29% <ø> (ø)` | `50.00 <ø> (ø)` | |
| #hudiutilities | `69.98% <ø> (ø)` | `325.00 <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [.../org/apache/hudi/common/model/HoodieTableType.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL0hvb2RpZVRhYmxlVHlwZS5qYXZh) | `100.00% <0.00%> (ø)` | `1.00% <0.00%> (ø%)` | |
| [...i/common/model/OverwriteWithLatestAvroPayload.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL092ZXJ3cml0ZVdpdGhMYXRlc3RBdnJvUGF5bG9hZC5qYXZh) | `64.70% <0.00%> (ø)` | `10.00% <0.00%> (ø%)` | |
| [...del/OverwriteNonDefaultsWithLatestAvroPayload.java](https://codecov.io/gh/apache/hudi/pull/2161/diff?src=pr&el=tree#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL092ZXJ3cml0ZU5vbkRlZmF1bHRzV2l0aExhdGVzdEF2cm9QYXlsb2FkLmphdmE=) | `78.94% <0.00%> (ø)` | `5.00% <0.00%> (ø%)` | |
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codecov-io edited a comment on pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#issuecomment-706340613
# [Codecov](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=h1) Report
> Merging [#2161](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=desc) into [master](https://codecov.io/gh/apache/hudi/commit/1d1d91d444b6af2b24b17d94068512a930877a98?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/hudi/pull/2161?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #2161 +/- ##
=========================================
Coverage 53.61% 53.61%
Complexity 2845 2845
=========================================
Files 359 359
Lines 16535 16535
Branches 1777 1777
=========================================
Hits 8866 8866
Misses 6912 6912
Partials 757 757
```
| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| #hudicli | `38.37% <ø> (ø)` | `193.00 <ø> (ø)` | |
| #hudiclient | `100.00% <ø> (ø)` | `0.00 <ø> (ø)` | |
| #hudicommon | `54.74% <ø> (ø)` | `1793.00 <ø> (ø)` | |
| #hudihadoopmr | `33.05% <ø> (ø)` | `181.00 <ø> (ø)` | |
| #hudispark | `65.51% <ø> (ø)` | `303.00 <ø> (ø)` | |
| #huditimelineservice | `62.29% <ø> (ø)` | `50.00 <ø> (ø)` | |
| #hudiutilities | `69.98% <ø> (ø)` | `325.00 <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] leesf commented on a change in pull request #2161: [HUDI-1328] Introduce HoodieFlinkEngineContext to hudi-flink-client
Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #2161:
URL: https://github.com/apache/hudi/pull/2161#discussion_r502729011
##########
File path: hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/common/function/FunctionWrapper.java
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.hudi.client.common.function;
+
+import scala.Tuple2;
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+/**
+ * Function wrapper util class, which catches the exception thrown by input function and return a similar function
+ * with no exception thrown.
+ */
+public class FunctionWrapper {
+
+ public static <I, O> Function<I, O> throwingMapWrapper(SerializableFunction<I, O> throwingMapFunction) {
+ return v1 -> {
+ try {
+ return throwingMapFunction.apply(v1);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
Review comment:
use HoodieException?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org