File tree Expand file tree Collapse file tree
hudi-client/hudi-client-common/src
main/java/org/apache/hudi/config
test/java/org/apache/hudi/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ public class HoodieLayoutConfig extends HoodieConfig {
4848 .noDefaultValue ()
4949 .withDocumentation ("Partitioner class, it is used to distribute data in a specific way." );
5050
51+ public static final String SIMPLE_BUCKET_LAYOUT_PARTITIONER_CLASS_NAME =
52+ "org.apache.hudi.table.action.commit.SparkBucketIndexPartitioner" ;
53+
5154 private HoodieLayoutConfig () {
5255 super ();
5356 }
@@ -80,8 +83,14 @@ public HoodieLayoutConfig build() {
8083 }
8184
8285 private void setDefault () {
83- if (layoutConfig .contains (HoodieIndexConfig .INDEX_TYPE .key ()) && layoutConfig .getString (HoodieIndexConfig .INDEX_TYPE .key ()).equals (HoodieIndex .IndexType .BUCKET .name ())) {
86+ if (layoutConfig .contains (HoodieIndexConfig .INDEX_TYPE .key ())
87+ && layoutConfig .getString (HoodieIndexConfig .INDEX_TYPE .key ()).equals (HoodieIndex .IndexType .BUCKET .name ())) {
8488 layoutConfig .setDefaultValue (LAYOUT_TYPE , HoodieStorageLayout .LayoutType .BUCKET .name ());
89+
90+ // Currently, the partitioner of the SIMPLE bucket index is supported by SparkBucketIndexPartitioner only.
91+ if ("SIMPLE" .equals (layoutConfig .getString (HoodieIndexConfig .BUCKET_INDEX_ENGINE_TYPE ))) {
92+ layoutConfig .setDefaultValue (LAYOUT_PARTITIONER_CLASS_NAME , SIMPLE_BUCKET_LAYOUT_PARTITIONER_CLASS_NAME );
93+ }
8594 }
8695 layoutConfig .setDefaultValue (LAYOUT_TYPE , LAYOUT_TYPE .defaultValue ());
8796 }
Original file line number Diff line number Diff line change @@ -371,6 +371,23 @@ public void testAutoConcurrencyConfigAdjustmentWithMetadataTableDisabled(HoodieT
371371 HoodieFailedWritesCleaningPolicy .LAZY , FileSystemBasedLockProviderTestClass .class .getName ());
372372 }
373373
374+ @ Test
375+ public void testSimpleBucketIndexPartitionerConfig () {
376+ HoodieWriteConfig writeConfig = HoodieWriteConfig .newBuilder ().withPath ("/tmp" )
377+ .withIndexConfig (HoodieIndexConfig .newBuilder ().withIndexType (HoodieIndex .IndexType .BUCKET )
378+ .withBucketIndexEngineType (HoodieIndex .BucketIndexEngineType .SIMPLE ).build ())
379+ .build ();
380+ assertEquals (HoodieLayoutConfig .SIMPLE_BUCKET_LAYOUT_PARTITIONER_CLASS_NAME , writeConfig .getString (HoodieLayoutConfig .LAYOUT_PARTITIONER_CLASS_NAME ));
381+
382+ HoodieWriteConfig overwritePartitioner = HoodieWriteConfig .newBuilder ().withPath ("/tmp" )
383+ .withIndexConfig (HoodieIndexConfig .newBuilder ().withIndexType (HoodieIndex .IndexType .BUCKET )
384+ .withBucketIndexEngineType (HoodieIndex .BucketIndexEngineType .SIMPLE )
385+ .build ())
386+ .withLayoutConfig (HoodieLayoutConfig .newBuilder ().withLayoutPartitioner ("org.apache.hudi.table.action.commit.UpsertPartitioner" ).build ())
387+ .build ();
388+ assertEquals ("org.apache.hudi.table.action.commit.UpsertPartitioner" , overwritePartitioner .getString (HoodieLayoutConfig .LAYOUT_PARTITIONER_CLASS_NAME ));
389+ }
390+
374391 private HoodieWriteConfig createWriteConfig (Map <String , String > configs ) {
375392 final Properties properties = new Properties ();
376393 configs .forEach (properties ::setProperty );
You can’t perform that action at this time.
0 commit comments