yihua commented on code in PR #11761:
URL: https://github.com/apache/hudi/pull/11761#discussion_r1717914121
##########
hudi-common/src/main/java/org/apache/hudi/common/engine/HoodieReaderContext.java:
##########
@@ -165,10 +167,50 @@ public void setShouldMergeUseRecordPosition(boolean
shouldMergeUseRecordPosition
* @param storage {@link HoodieStorage} for reading records.
* @return {@link ClosableIterator<T>} that can return all records through
iteration.
*/
- public abstract ClosableIterator<T> getFileRecordIterator(
+ protected abstract ClosableIterator<T> getFileRecordIterator(
StoragePath filePath, long start, long length, Schema dataSchema, Schema
requiredSchema,
HoodieStorage storage) throws IOException;
+ /**
+ * Gets the record iterator based on the type of engine-specific record
representation from the
+ * file.
+ *
+ * @param file {@link StorageFile} instance of a file.
+ * @param start Starting byte to start reading.
+ * @param length Bytes to read.
+ * @param dataSchema Schema of records in the file in {@link Schema}.
+ * @param requiredSchema Schema containing required fields to read in {@link
Schema} for projection.
+ * @param storage {@link HoodieStorage} for reading records.
+ * @return {@link ClosableIterator<T>} that can return all records through
iteration.
+ */
+ public final ClosableIterator<T> getFileRecordIterator(
+ StorageFile file, long start, long length, Schema dataSchema, Schema
requiredSchema,
Review Comment:
It seems that these two new methods and `StorageFile` are not strictly
necessary, and they adds more overhead of maintaining the new interface.
##########
hudi-common/src/main/java/org/apache/hudi/common/engine/HoodieReaderContext.java:
##########
@@ -165,10 +167,50 @@ public void setShouldMergeUseRecordPosition(boolean
shouldMergeUseRecordPosition
* @param storage {@link HoodieStorage} for reading records.
* @return {@link ClosableIterator<T>} that can return all records through
iteration.
*/
- public abstract ClosableIterator<T> getFileRecordIterator(
+ protected abstract ClosableIterator<T> getFileRecordIterator(
StoragePath filePath, long start, long length, Schema dataSchema, Schema
requiredSchema,
HoodieStorage storage) throws IOException;
+ /**
+ * Gets the record iterator based on the type of engine-specific record
representation from the
+ * file.
+ *
+ * @param file {@link StorageFile} instance of a file.
+ * @param start Starting byte to start reading.
+ * @param length Bytes to read.
+ * @param dataSchema Schema of records in the file in {@link Schema}.
+ * @param requiredSchema Schema containing required fields to read in {@link
Schema} for projection.
+ * @param storage {@link HoodieStorage} for reading records.
+ * @return {@link ClosableIterator<T>} that can return all records through
iteration.
+ */
+ public final ClosableIterator<T> getFileRecordIterator(
+ StorageFile file, long start, long length, Schema dataSchema, Schema
requiredSchema,
+ HoodieStorage storage) throws IOException {
+ if (file.getPathInfo() != null) {
+ return getFileRecordIterator(file.getPathInfo(), start, length,
dataSchema, requiredSchema, storage);
+ } else {
+ return getFileRecordIterator(file.getStoragePath(), start, length,
dataSchema, requiredSchema, storage);
+ }
+ }
+
+ /**
+ * Gets the record iterator based on the type of engine-specific record
representation from the
+ * file.
+ *
+ * @param storagePathInfo {@link StoragePathInfo} instance of a file.
+ * @param start Starting byte to start reading.
+ * @param length Bytes to read.
+ * @param dataSchema Schema of records in the file in {@link Schema}.
+ * @param requiredSchema Schema containing required fields to read in
{@link Schema} for projection.
+ * @param storage {@link HoodieStorage} for reading records.
+ * @return {@link ClosableIterator<T>} that can return all records through
iteration.
+ */
+ protected ClosableIterator<T> getFileRecordIterator(
+ StoragePathInfo storagePathInfo, long start, long length, Schema
dataSchema, Schema requiredSchema,
+ HoodieStorage storage) throws IOException {
+ return getFileRecordIterator(storagePathInfo.getPath(), start, length,
dataSchema, requiredSchema, storage);
Review Comment:
Adding to the above, only the path is used within the `StorageFile`
instance. So this util does not add much value.
##########
hudi-io/src/main/java/org/apache/hudi/storage/StorageFile.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.storage;
+
+public interface StorageFile {
Review Comment:
Without this, by adding the locations to `StoragePathInfo`, the same goal
can be achieved.
##########
hudi-common/src/main/java/org/apache/hudi/common/engine/HoodieReaderContext.java:
##########
@@ -165,10 +167,50 @@ public void setShouldMergeUseRecordPosition(boolean
shouldMergeUseRecordPosition
* @param storage {@link HoodieStorage} for reading records.
* @return {@link ClosableIterator<T>} that can return all records through
iteration.
*/
- public abstract ClosableIterator<T> getFileRecordIterator(
+ protected abstract ClosableIterator<T> getFileRecordIterator(
StoragePath filePath, long start, long length, Schema dataSchema, Schema
requiredSchema,
Review Comment:
Can we keep this only? The caller should know the path to use. Otherwise,
we may hide issues where path info is null.
--
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]