cshuo commented on code in PR #19765:
URL: https://github.com/apache/hudi/pull/19765#discussion_r3877855524


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/index/PartitionedIndexBackendFactory.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.index;
+
+import org.apache.hudi.configuration.FlinkOptions;
+
+import org.apache.flink.configuration.Configuration;
+
+/**
+ * Factory to create a {@link PartitionedIndexBackend} used by the dynamic 
bucket assign function.
+ */
+public class PartitionedIndexBackendFactory {
+  private static final String ROCKSDB_BACKEND_TYPE = "rocksdb";
+
+  /**
+   * Creates the partitioned index backend used to look up and record {@code 
recordKey -> fileGroupId}
+   * mappings for the partitioned record level index.
+   *
+   * @param conf Flink write configuration
+   * @param isInsertOverwrite whether the write operation is an insert 
overwrite, in which case indexing is skipped
+   * @param bootstrapFilter filter for deciding whether a bootstrapped RLI 
record belongs to this task,
+   *                        used only by the metadata-table-backed backend
+   * @return partitioned index backend for record-key lookups scoped to a data 
partition
+   */
+  public static PartitionedIndexBackend create(
+      Configuration conf,
+      boolean isInsertOverwrite,
+      RecordLevelIndexBackend.BootstrapFilter bootstrapFilter) {
+    if (isInsertOverwrite) {
+      return new DummyPartitionedIndexBackend();
+    }
+    String backendType = conf.get(FlinkOptions.INDEX_RLI_BACKEND_TYPE);
+    if (ROCKSDB_BACKEND_TYPE.equalsIgnoreCase(backendType)) {

Review Comment:
   Selecting `rocksdb` here bypasses the MDT-backed `RecordLevelIndexBackend`, 
but this backend starts empty and neither bootstraps from nor falls back to the 
authoritative MDT RLI. On a non-empty table or after task/job restart, 
committed keys therefore miss in `get()` and `DynamicBucketAssignFunction` 
routes them as inserts, potentially assigning a second file group to an 
existing key.
   
   In addition, the first `update()` registers the column family after loading 
only one key, which violates RFC-107's partition-completeness invariant. Please 
keep this backend non-selectable until partition bootstrap/on-demand MDT 
loading is implemented, or compose it with the MDT backend and register a 
partition only after its complete RLI state has been loaded. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to