manojpec commented on a change in pull request #4067:
URL: https://github.com/apache/hudi/pull/4067#discussion_r768490715



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieHFileKeyExcludedReader.java
##########
@@ -0,0 +1,85 @@
+/*
+ * 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;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.io.hfile.CacheConfig;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.ValidationUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * HFile reader for the Metadata table log files. Metadata table records in the
+ * HFile data blocks have the redundant key field in the record payload 
trimmed.
+ * So, when the log reader is reading records, materialization of such trimmed
+ * records must be done before handing the records to the callers. This class
+ * takes care of Metadata table record materialization, any needed.
+ *
+ * @param <R> Metadata table record type.
+ */
+public class HoodieHFileKeyExcludedReader<R extends IndexedRecord> extends 
HoodieHFileReader<R> {
+
+  private static final Logger LOG = 
LogManager.getLogger(HoodieHFileKeyExcludedReader.class);
+
+  public HoodieHFileKeyExcludedReader(Configuration configuration, Path path, 
CacheConfig cacheConfig,
+                                      Option<String> keyField) throws 
IOException {
+    super(configuration, path, cacheConfig, keyField);
+  }
+
+  public HoodieHFileKeyExcludedReader(Configuration configuration, Path path, 
CacheConfig cacheConfig, FileSystem inlineFs,
+                                      String keyField) throws IOException {
+    super(configuration, path, cacheConfig, inlineFs, keyField);
+  }
+
+  public HoodieHFileKeyExcludedReader(final byte[] content, final String 
keyField) throws IOException {
+    super(content, keyField);
+  }
+
+  /**
+   * Materialize the record key field.
+   *
+   * @param keyField - Key field in the schema
+   * @param keyBytes - Key byte array
+   * @param record   - Record to materialize
+   */
+  @Override
+  protected void materializeRecordIfNeeded(final Option<String> keyField, 
final ByteBuffer keyBytes, R record) {
+    if (!keyField.isPresent()) {

Review comment:
       more of defensive coding. don't have a case where this could happen. 
will explore more and remove it if not needed.




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