zhangyue19921010 commented on code in PR #13225:
URL: https://github.com/apache/hudi/pull/13225#discussion_r2061325941


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/BufferedRecord.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.common.table.read;
+
+import org.apache.hudi.common.engine.HoodieReaderContext;
+import org.apache.hudi.common.model.DeleteRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.exception.HoodieException;
+
+import org.apache.avro.Schema;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Properties;
+
+import static org.apache.hudi.common.model.HoodieRecord.DEFAULT_ORDERING_VALUE;
+
+/**
+ * Buffered Record used by file group reader.
+ *
+ * @param <T> The type of the engine specific row.
+ */
+public class BufferedRecord<T> implements Serializable {

Review Comment:
   We already have `HoodieRecord`. Why we still need a new `BufferedRecord`



##########
hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroReaderContext.java:
##########
@@ -160,24 +161,27 @@ public String getRecordKey(IndexedRecord record, Schema 
schema) {
   }
 
   @Override
-  public HoodieRecord constructHoodieRecord(
-      Option<IndexedRecord> recordOpt,
-      Map<String, Object> metadataMap) {
-    if (!recordOpt.isPresent()) {
+  public HoodieRecord<IndexedRecord> 
constructHoodieRecord(BufferedRecord<IndexedRecord> bufferedRecord) {
+    if (bufferedRecord.isDelete()) {
       return SpillableMapUtils.generateEmptyPayload(
-          (String) metadataMap.get(INTERNAL_META_RECORD_KEY),
-          (String) metadataMap.get(INTERNAL_META_PARTITION_PATH),
-          (Comparable<?>) metadataMap.get(INTERNAL_META_ORDERING_FIELD),
+          bufferedRecord.getRecordKey(),
+          null,

Review Comment:
   Why we no longer need metadataMap.get(INTERNAL_META_PARTITION_PATH) 
information?



##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieRecord.java:
##########
@@ -211,7 +213,14 @@ public HoodieOperation getOperation() {
     return operation;
   }
 
-  public abstract Comparable<?> getOrderingValue(Schema recordSchema, 
Properties props);
+  public Comparable<?> getOrderingValue(Schema recordSchema, Properties props) 
{
+    if (orderingValue == null) {
+      orderingValue = doGetOrderingValue(recordSchema, props);
+    }
+    return orderingValue;
+  }
+
+  protected abstract Comparable<?> doGetOrderingValue(Schema recordSchema, 
Properties props);

Review Comment:
   could u add java doc to explain the difference between `doGetOrderingValue` 
and `getOrderingValue` to avoid confusing. maybe we can rename to something 
like `extractOrderingValueFromData`?



##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/common/model/HoodieSparkRecord.java:
##########
@@ -89,6 +89,8 @@ public class HoodieSparkRecord extends 
HoodieRecord<InternalRow> {
    */
   private final transient StructType schema;
 
+  private transient Comparable<?> orderingValue;

Review Comment:
   A new variable `orderingValue` is defined, which seems to be used to cache 
the ordering value, but I don’t see where it is initialized or called.



##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/hudi/BaseSparkInternalRowReaderContext.java:
##########
@@ -112,6 +112,15 @@ public InternalRow seal(InternalRow internalRow) {
     return internalRow.copy();
   }
 
+  @Override
+  public InternalRow toBinaryRow(Schema schema, InternalRow internalRow) {
+    if (internalRow instanceof UnsafeRow) {
+      return internalRow;
+    }
+    final UnsafeProjection unsafeProjection = 
HoodieInternalRowUtils.getCachedUnsafeProjection(schema);

Review Comment:
   In PR https://github.com/apache/hudi/pull/12949 we have an avro schema cache 
using Caffeine, which could improve  performance in 
HoodieInternalRowUtils.getCachedXXX,would do mind to take care of similar 
questions calling getCachedUnsafeProjection function?



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