danny0405 commented on code in PR #19072:
URL: https://github.com/apache/hudi/pull/19072#discussion_r3485137908


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieNativeDataBlock.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.log.block;
+
+import org.apache.hudi.common.engine.HoodieReaderContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.HoodieFileFormat;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.schema.HoodieSchema;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.ClosableIterator;
+import org.apache.hudi.io.SeekableDataInputStream;
+import org.apache.hudi.io.storage.HoodieIOFactory;
+import org.apache.hudi.storage.HoodieStorage;
+import org.apache.hudi.storage.StoragePath;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.hudi.common.util.ConfigUtils.DEFAULT_HUDI_CONFIG_FOR_READER;
+
+/**
+ * Data block backed by a native log file.
+ */
+public class HoodieNativeDataBlock extends HoodieDataBlock {
+
+  private final HoodieStorage storage;
+  private final HoodieLogFile logFile;
+  private final HoodieFileFormat fileFormat;
+
+  public HoodieNativeDataBlock(HoodieStorage storage,
+                               HoodieLogFile logFile,
+                               HoodieFileFormat fileFormat,
+                               Option<HoodieSchema> readerSchema,
+                               Map<HeaderMetadataType, String> header,
+                               Map<FooterMetadataType, String> footer) {
+    super(Option.empty(), null, true, Option.empty(), readerSchema,
+        header, footer, HoodieRecord.RECORD_KEY_METADATA_FIELD, false);
+    this.storage = storage;
+    this.logFile = logFile;
+    this.fileFormat = fileFormat;
+  }
+
+  @Override
+  public HoodieLogBlockType getBlockType() {
+    return HoodieLogBlockType.NATIVE_DATA_BLOCK;
+  }
+
+  @Override
+  protected <T> ClosableIterator<HoodieRecord<T>> 
readRecordsFromBlockPayload(HoodieRecord.HoodieRecordType type) throws 
IOException {
+    StoragePath path = logFile.getPath();
+    return HoodieIOFactory.getIOFactory(storage)
+        .getReaderFactory(type)
+        .getFileReader(DEFAULT_HUDI_CONFIG_FOR_READER, path, fileFormat, 
Option.empty())
+        .getRecordIterator(getSchemaFromHeader(), readerSchema);
+  }
+
+  @Override
+  protected <T> ClosableIterator<HoodieRecord<T>> 
readRecordsFromBlockPayload(HoodieRecord.HoodieRecordType type, int 
ignoredBufferSize) throws IOException {
+    return readRecordsFromBlockPayload(type);
+  }
+
+  @Override
+  protected <T> ClosableIterator<T> 
readRecordsFromBlockPayload(HoodieReaderContext<T> readerContext) throws 
IOException {

Review Comment:
   Key-filtered scans will fail for native data logs here. 
`FileGroupRecordBuffer.getRecordsIterator` calls 
`dataBlock.getEngineRecordIterator(readerContext, keys, fullKey)` whenever 
`HoodieMergedLogRecordReader.createKeySpec(...)` builds an `IN`/`STARTS_WITH` 
filter. The base `HoodieDataBlock` implementation routes that to 
`lookupEngineRecords`, which this block does not override, so `.log.parquet` 
files throw `Point lookups are not supported by this Data block type 
(NATIVE_DATA_BLOCK)` instead of returning the matching rows. Since native logs 
are meant to be transparent to the file-group reader, please add a 
scan-and-filter fallback (or native predicate pushdown) for 
`lookupEngineRecords` here and cover an `IN`/prefix-filtered read test.



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