nsivabalan commented on code in PR #19045:
URL: https://github.com/apache/hudi/pull/19045#discussion_r3611503315


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieAppendHandle.java:
##########
@@ -268,6 +275,37 @@ private void init(HoodieRecord record) {
     doInit = false;
   }
 
+  /**
+   * Returns true when this append handle is writing to a layout sub-path of 
an MDT partition
+   * (e.g. {@code record_index/0004} under sub-directory bucketing). In that 
case, the
+   * {@code .hoodie_partition_metadata} marker must NOT be created at the 
bucket level; it is
+   * written once at the logical partition root by the MDT initialization path.
+   *
+   * <p>Heuristic: an MDT partition path of the form {@code 
<known-mdt-partition>/<NNNN>} where
+   * {@code NNNN} is the standard 4-digit bucket name produced by the 
sub-directory bucketing
+   * layout. Third-party layouts using a different sub-path naming scheme can 
ship their own
+   * append-handle integration; the OSS-shipped layouts use this convention.
+   */
+  private boolean isMDTLayoutSubPath(String physicalPartitionPath) {

Review Comment:
   Partially addressed in `0eac426fa1ac`:
   
   - **Brittleness (10K bucket overflow)**: bucket-index width widened from 
`%04d` to `%06d` in `SubDirBucketedMDTLayout`. Added a `BUCKET_INDEX_WIDTH = 6` 
constant and `MAX_BUCKETS = 1_000_000` with a `ValidationUtils.checkArgument` 
gate so overflow throws rather than silently misbehaves. 
`HoodieTableMetadataUtil.isMDTBucketSubPath` consumes the same constant. Raises 
the ceiling by 100× and closes the "marker inside bucket dir → invariant 
collapse" failure mode.
   
   - **Layering (heuristic vs. SPI delegation)**: not addressed in this pass. 
The heuristic still hard-codes the "N-digit suffix" test (just with wider N 
now). Making `isMDTBucketSubPath` delegate to 
`HoodieMetadataTableLayout.getPartitionMarkerPaths` (or a new predicate on the 
SPI) is a follow-up — happy to file it as a separate refactor rather than 
expand this PR further.



##########
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java:
##########
@@ -1514,27 +1514,52 @@ private static List<FileSlice> 
getPartitionFileSlices(HoodieTableMetaClient meta
     HoodieTableFileSystemView fsView = null;
     try {
       fsView = fileSystemView.orElseGet(() -> 
getFileSystemViewForMetadataTable(metaClient));
-      Stream<FileSlice> fileSliceStream;
-      if (mergeFileSlices) {
-        if 
(metaClient.getActiveTimeline().filterCompletedInstants().lastInstant().isPresent())
 {
-          fileSliceStream = fsView.getLatestMergedFileSlicesBeforeOrOn(
-              // including pending compaction instant as the last instant so 
that the finished delta commits
-              // that start earlier than the compaction can be queried.
-              partition, 
metaClient.getActiveTimeline().filterCompletedAndCompactionInstants().lastInstant().get().requestedTime());
+      List<String> physicalPartitions = resolvePhysicalPartitions(metaClient, 
partition);
+      List<FileSlice> all = new ArrayList<>();
+      boolean any = false;

Review Comment:
   Good nit — will fold this into a follow-up cleanup pass so the trailing 
`any`-flag pattern gets replaced with an `if (physicalPartitions.isEmpty()) 
return Collections.emptyList();` guard before the loop.



##########
hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java:
##########
@@ -696,6 +696,32 @@ public long getMaxLogFileSize() {
     return getLong(MAX_LOG_FILE_SIZE_BYTES_PROP);
   }
 
+  public static final ConfigProperty<String> METADATA_LAYOUT_CLASS = 
ConfigProperty
+      .key("hoodie.metadata.layout.class")
+      .noDefaultValue()
+      .markAdvanced()
+      .sinceVersion("1.3.0")
+      .withDocumentation("Fully-qualified class name of the 
HoodieMetadataTableLayout implementation that organizes "
+          + "MDT file groups on disk. When unset, MDT uses the flat layout 
(file groups directly under each metadata "
+          + "partition). Applies only at MDT initialization; an MDT already on 
disk keeps its existing layout.");

Review Comment:
   Done in `92fe6e19`. `HoodieMetadataConfig.METADATA_LAYOUT_CLASS` doc now 
enumerates the OOB values: (1) unset / `FlatMDTLayout` (default, bit-identical 
to pre-SPI behavior) and (2) `SubDirBucketedMDTLayout`.



##########
hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java:
##########
@@ -696,6 +696,32 @@ public long getMaxLogFileSize() {
     return getLong(MAX_LOG_FILE_SIZE_BYTES_PROP);
   }
 
+  public static final ConfigProperty<String> METADATA_LAYOUT_CLASS = 
ConfigProperty
+      .key("hoodie.metadata.layout.class")
+      .noDefaultValue()
+      .markAdvanced()
+      .sinceVersion("1.3.0")
+      .withDocumentation("Fully-qualified class name of the 
HoodieMetadataTableLayout implementation that organizes "
+          + "MDT file groups on disk. When unset, MDT uses the flat layout 
(file groups directly under each metadata "
+          + "partition). Applies only at MDT initialization; an MDT already on 
disk keeps its existing layout.");
+
+  public static final ConfigProperty<Integer> METADATA_LAYOUT_BUCKET_SIZE = 
ConfigProperty
+      .key("hoodie.metadata.layout.bucket.size")
+      .defaultValue(1000)
+      .markAdvanced()
+      .sinceVersion("1.3.0")
+      .withDocumentation("When the layout is SubDirBucketedMDTLayout, the 
maximum number of file groups per bucket "

Review Comment:
   Done in `92fe6e19`. `HoodieMetadataConfig.METADATA_LAYOUT_BUCKET_SIZE` doc 
now cross-references `hoodie.metadata.layout.class` so users find the sibling 
knob.



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