hudi-agent commented on code in PR #18897:
URL: https://github.com/apache/hudi/pull/18897#discussion_r3345346471


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/configuration/OptionsResolver.java:
##########
@@ -258,6 +258,24 @@ public static boolean 
isSimpleBucketIndexType(Configuration conf) {
     return isBucketIndexType(conf) && 
getBucketEngineType(conf).equals(HoodieIndex.BucketIndexEngineType.SIMPLE);
   }
 
+  /**
+   * Returns whether the simple bucket index should use remote partitioner.
+   */
+  public static boolean enableBucketRemotePartitioner(Configuration conf) {

Review Comment:
   🤖 nit: `enableBucketRemotePartitioner` reads as a command ("enable it") 
rather than a predicate, which could mislead a reader into thinking this is a 
side-effecting method. Could you rename it to something like 
`shouldUseBucketRemotePartitioner` or `isBucketRemotePartitionerActive` to make 
it clear it's a pure check?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/BucketIndexRemotePartitioner.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.HoodieKey;
+import org.apache.hudi.common.table.view.FileSystemViewStorageConfig;
+import org.apache.hudi.common.util.RemotePartitionHelper;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.index.bucket.BucketIdentifier;
+import org.apache.hudi.index.bucket.partition.NumBucketsFunction;
+import org.apache.hudi.util.ViewStorageProperties;
+
+import org.apache.flink.api.common.functions.Partitioner;
+import org.apache.flink.configuration.Configuration;
+
+/**
+ * Bucket index input partitioner backed by the embedded timeline service.
+ *
+ * @param <T> The type of object to hash
+ */
+public class BucketIndexRemotePartitioner<T extends HoodieKey> implements 
Partitioner<T> {
+
+  private final Configuration conf;
+  private final String indexKeyFields;
+  private final NumBucketsFunction numBucketsFunction;
+
+  private transient RemotePartitionHelper remotePartitionHelper;
+
+  public BucketIndexRemotePartitioner(Configuration conf, String 
indexKeyFields) {
+    this.conf = conf;
+    this.indexKeyFields = indexKeyFields;
+    this.numBucketsFunction = new 
NumBucketsFunction(conf.get(FlinkOptions.BUCKET_INDEX_PARTITION_EXPRESSIONS),
+        conf.get(FlinkOptions.BUCKET_INDEX_PARTITION_RULE), 
conf.get(FlinkOptions.BUCKET_INDEX_NUM_BUCKETS));
+  }
+
+  @Override
+  public int partition(T key, int numPartitions) {
+    String partitionPath = normalizePartitionPath(key.getPartitionPath());
+    int numBuckets = numBucketsFunction.getNumBuckets(partitionPath);
+    int curBucket = BucketIdentifier.getBucketId(key.getRecordKey(), 
indexKeyFields, numBuckets);
+    return getRemotePartition(getRemotePartitionHelper(), numBucketsFunction, 
partitionPath, curBucket, numPartitions);
+  }
+
+  public static int getRemotePartition(
+      RemotePartitionHelper remotePartitionHelper,
+      NumBucketsFunction numBucketsFunction,
+      String partitionPath,
+      int curBucket,
+      int partitionNum) {

Review Comment:
   🤖 nit: `partitionNum` could be misread as "a specific partition index" 
rather than "total number of partitions". Could you rename it to 
`numPartitions` to match the Flink `Partitioner` interface's own parameter name 
and the instance method above?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/bucket/BucketStreamWriteFunction.java:
##########
@@ -75,6 +77,11 @@ public class BucketStreamWriteFunction extends 
StreamWriteFunction {
    * Functions for calculating the task partition to dispatch.
    */
   private Functions.Function3<Integer, String, Integer, Integer> 
partitionIndexFunc;
+
+  private boolean remotePartitionerEnabled;

Review Comment:
   🤖 nit: other boolean fields in this class (e.g. `isInsertOverwrite`) use the 
`is` prefix — could you rename this to `isRemotePartitionerEnabled` for 
consistency?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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