garyli1019 commented on a change in pull request #2958:
URL: https://github.com/apache/hudi/pull/2958#discussion_r633347247
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/BucketAssignFunction.java
##########
@@ -90,7 +92,7 @@
* <li>If it does not, use the {@link BucketAssigner} to generate a new
bucket ID</li>
* </ul>
*/
- private MapState<HoodieKey, HoodieRecordLocation> indexState;
+ private MapState<String, GlobalHoodieRecordLocation> indexState;
Review comment:
If we need to support a global index, we need to use a single source
across parallelisms as the index store right? How does this distributed state
ensure the consistency of the result? Let's say for the case that we change the
parallelism and restart the job. The keys and parallelism hash mapping were
reorganized.
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/GlobalHoodieRecordLocation.java
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.sink.partitioner;
+
+import org.apache.hudi.common.model.HoodieRecordLocation;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Similar with {@link org.apache.hudi.common.model.HoodieRecordLocation} but
with partition path.
+ */
+public class GlobalHoodieRecordLocation implements Serializable {
Review comment:
This looks like a `HoodieRecordLocation` + partition path. Can we extend
from it and put this to hudi-common module?
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/GlobalHoodieRecordLocation.java
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.sink.partitioner;
+
+import org.apache.hudi.common.model.HoodieRecordLocation;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Similar with {@link org.apache.hudi.common.model.HoodieRecordLocation} but
with partition path.
+ */
+public class GlobalHoodieRecordLocation implements Serializable {
Review comment:
I think that's necessary, maybe other engines will use this later. How
about renaming this to `HoodieRecordGlobalLocation`
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/BucketAssignFunction.java
##########
@@ -90,7 +92,7 @@
* <li>If it does not, use the {@link BucketAssigner} to generate a new
bucket ID</li>
* </ul>
*/
- private MapState<HoodieKey, HoodieRecordLocation> indexState;
+ private MapState<String, GlobalHoodieRecordLocation> indexState;
Review comment:
Also, the global index is very expensive for a large table. Can we make
the index type configurable?
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/BucketAssignFunction.java
##########
@@ -90,7 +92,7 @@
* <li>If it does not, use the {@link BucketAssigner} to generate a new
bucket ID</li>
* </ul>
*/
- private MapState<HoodieKey, HoodieRecordLocation> indexState;
+ private MapState<String, GlobalHoodieRecordLocation> indexState;
Review comment:
Let me give an example. When a record changes the partition, we will
create a delete record to the old location and update the index with the new
location, but this index state was globally distributed and only one
parallelism will be affected. If we change the parallelism and restart the job,
this record may be in different parallelism with a wrong location in the index
state.
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/BucketAssignFunction.java
##########
@@ -90,7 +92,7 @@
* <li>If it does not, use the {@link BucketAssigner} to generate a new
bucket ID</li>
* </ul>
*/
- private MapState<HoodieKey, HoodieRecordLocation> indexState;
+ private MapState<String, GlobalHoodieRecordLocation> indexState;
Review comment:
> > Let me give an example. When a record changes the partition, we will
create a delete record to the old location and update the index with the new
location, but this index state was globally distributed and only one
parallelism will be affected. If we change the parallelism and restart the job,
this record may be in different parallelism with a wrong location in the index
state.
>
> No worries, the flink state backed would keep the semantics for us.
That's interesting! I just started to learn Flink and found that the
keyedState was only responsible for local change. If we change the parallelism,
the data layout should be completely changed since the keyBy operation uses a
different parallelism number. Does Flink automatically sync the distributed
state for this case? Any doc for this feature?
##########
File path:
hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/GlobalHoodieRecordLocation.java
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.sink.partitioner;
+
+import org.apache.hudi.common.model.HoodieRecordLocation;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Similar with {@link org.apache.hudi.common.model.HoodieRecordLocation} but
with partition path.
+ */
+public class GlobalHoodieRecordLocation implements Serializable {
Review comment:
`HoodieRecord` is a noun. IMO the change should be from `Location` to
`GlobalLocation`
--
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:
[email protected]