voonhous commented on code in PR #18961:
URL: https://github.com/apache/hudi/pull/18961#discussion_r3449398527


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/io/storage/row/VariantShreddingInferenceInternalRowFileWriter.java:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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.io.storage.row;
+
+import org.apache.hudi.SparkAdapterSupport$;
+import org.apache.hudi.avro.VariantShreddingSchemaInferrer;
+import org.apache.hudi.avro.VariantShreddingSchemaInferrer.VariantSample;
+import org.apache.hudi.common.schema.HoodieSchema;
+import org.apache.hudi.common.util.DefaultSizeEstimator;
+import org.apache.hudi.io.storage.VariantShreddingInferenceFileWriter;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.spark.sql.catalyst.InternalRow;
+import org.apache.spark.sql.catalyst.expressions.UnsafeRow;
+import org.apache.spark.sql.types.StructField;
+import org.apache.spark.sql.types.StructType;
+import org.apache.spark.unsafe.types.UTF8String;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A {@link HoodieInternalRowFileWriter} decorator that infers a per-file 
variant shredding
+ * schema from the first rows before opening the real parquet writer; the 
row-writer-path
+ * sibling of {@link VariantShreddingInferenceFileWriter}, sharing its 
buffering thresholds and
+ * failure semantics.
+ *
+ * <p>Meta columns including the commit seqno are composed into the row by the 
handle BEFORE
+ * {@code writeRow}, so ordered replay is value-exact here by construction. 
Rows and keys are
+ * copied because Spark iterators reuse their instances.</p>
+ */
+@Slf4j
+public class VariantShreddingInferenceInternalRowFileWriter implements 
HoodieInternalRowFileWriter {
+
+  /** Creates the real row file writer once the inferred typed_value schemas 
are known. */
+  @FunctionalInterface
+  public interface InferredRowWriterFactory {
+    HoodieInternalRowFileWriter create(Map<String, HoodieSchema> 
inferredTypedValues) throws IOException;
+  }
+
+  private final List<String> variantColumns;
+  private final int[] ordinals;
+  private final VariantShreddingSchemaInferrer inferrer;
+  private final InferredRowWriterFactory writerFactory;
+  private final long maxBufferedBytes;
+  private final DefaultSizeEstimator<InternalRow> sizeEstimator = new 
DefaultSizeEstimator<>();
+
+  private static final int SIZE_ESTIMATE_INTERVAL = 100;
+
+  private final List<BufferedRow> buffer = new ArrayList<>();

Review Comment:
   Done - moved `SIZE_ESTIMATE_INTERVAL` to the top of the class, before the 
nested interface and instance fields, matching the sibling 
`VariantShreddingInferenceFileWriter`.



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