JingsongLi commented on code in PR #10394:
URL: https://github.com/apache/paimon/pull/10394#discussion_r4291197779


##########
paimon-core/src/main/java/org/apache/paimon/operation/DataEvolutionSplitRead.java:
##########
@@ -305,14 +324,41 @@ private RecordReader<InternalRow> createReader(
                                 groupSelection =
                                         buildGroupSelection(needMergeFiles, 
fileIndexResults);
                             }
-                            return createUnionReader(
-                                    needMergeFiles,
-                                    partition,
-                                    dataFilePathFactory,
-                                    rowRanges,
-                                    readRowType,
-                                    deletionVector,
-                                    groupSelection);
+                            FileMetadataCache metadataCache = new 
FileMetadataCache();
+                            List<Range> candidates =
+                                    candidateRanges(
+                                            filters,
+                                            needMergeFiles,
+                                            dataFilePathFactory,
+                                            metadataCache);
+                            // Candidates restrict the group selection, not 
the row ranges of the
+                            // split, which also decide whether a row sidecar 
is read instead.
+                            if (candidates != null) {
+                                if (candidates.isEmpty()) {
+                                    return new EmptyFileRecordReader<>();
+                                }
+                                groupSelection =
+                                        restrictToCandidates(
+                                                groupSelection, 
needMergeFiles.get(0), candidates);
+                                if (isSelectionEmpty(
+                                        needMergeFiles.get(0), rowRanges, 
groupSelection)) {
+                                    return new EmptyFileRecordReader<>();
+                                }
+                            }
+                            // the readers of a group are created right away, 
see #candidateRanges
+                            groupMetadataCache = metadataCache;

Review Comment:
   Could we keep this cache local to the merged-group construction and pass it 
explicitly through `createUnionReader` → `createFieldBunchReader` → 
`createFileReader`? It is created for one group and cleared immediately after 
its readers are constructed, so it does not need to be instance state. Using 
the field as a temporary parameter makes `createFileReader` depend on the 
caller having set it and on reader creation remaining synchronous. Explicit 
parameter passing would make the ownership and lifetime clear and remove the 
set/reset `try/finally`.



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