tejasiyer-dev commented on code in PR #40543:
URL: https://github.com/apache/beam/pull/40543#discussion_r4624318234


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/WriteFiles.java:
##########
@@ -579,8 +616,118 @@ public WriteFilesResult<DestinationT> 
expand(PCollection<UserT> input) {
         (getComputeNumShards() == null) ? null : 
input.apply(getComputeNumShards());
 
     boolean fixedSharding = getComputeNumShards() != null || 
getNumShardsProvider() != null;
+    // Records that take the grouped path, and files written directly (if any).
+    PCollection<UserT> groupedInput = input;
+    @Nullable PCollection<FileResult<DestinationT>> directFiles = null;
+    Long directWriteThreshold = getDirectWriteByteThreshold();
+    if (directWriteThreshold != null) {
+      List<String> disabledReasons = new ArrayList<>();
+      // Without a fixed shard count, bounded inputs already write each bundle 
directly.
+      if (input.isBounded() == IsBounded.BOUNDED && !fixedSharding) {
+        disabledReasons.add("the input is bounded without a fixed number of 
shards");
+      }
+      if (!getSideInputs().isEmpty()) {
+        disabledReasons.add("dynamic destinations use side inputs");
+      }
+      // Merging windows are only final after the GroupByKey, so direct writes 
would use
+      // unmerged windows.
+      if (input.getWindowingStrategy().needsMerge()) {

Review Comment:
   Yes, WriteFiles supports merging windows when a fixed shard count is set, 
since GroupIntoShards uses a GroupByKey that merges them. 
   
   Because direct writes also apply when withNumShards is set, this check 
prevents writing files with unmerged windows before GroupByKey.



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