This is an automated email from the ASF dual-hosted git repository. lzljs3620320 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push: new ff02f6bf3c [core] Refactor limit in FileIndexEvaluator.evaluate ff02f6bf3c is described below commit ff02f6bf3ceccf8dcac38bc58cf6db390509bd46 Author: JingsongLi <jingsongl...@gmail.com> AuthorDate: Wed Aug 20 17:58:33 2025 +0800 [core] Refactor limit in FileIndexEvaluator.evaluate --- .../paimon/fileindex/bitmap/BitmapIndexResult.java | 2 +- .../org/apache/paimon/io/FileIndexEvaluator.java | 35 ++++++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapIndexResult.java b/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapIndexResult.java index fd4991bdf7..cc20918a69 100644 --- a/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapIndexResult.java +++ b/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapIndexResult.java @@ -55,7 +55,7 @@ public class BitmapIndexResult extends LazyField<RoaringBitmap32> implements Fil return FileIndexResult.super.or(fileIndexResult); } - public FileIndexResult andNot(RoaringBitmap32 deletion) { + public BitmapIndexResult andNot(RoaringBitmap32 deletion) { return new BitmapIndexResult(() -> RoaringBitmap32.andNot(get(), deletion)); } diff --git a/paimon-core/src/main/java/org/apache/paimon/io/FileIndexEvaluator.java b/paimon-core/src/main/java/org/apache/paimon/io/FileIndexEvaluator.java index 1b4f3d1776..0a5505d48d 100644 --- a/paimon-core/src/main/java/org/apache/paimon/io/FileIndexEvaluator.java +++ b/paimon-core/src/main/java/org/apache/paimon/io/FileIndexEvaluator.java @@ -50,22 +50,15 @@ public class FileIndexEvaluator { @Nullable Integer limit, DataFilePathFactory dataFilePathFactory, DataFileMeta file, - @Nullable DeletionVector deletionVector) + @Nullable DeletionVector dv) throws IOException { - if (isNullOrEmpty(dataFilter) && topN == null && limit == null) { - return FileIndexResult.REMAIN; - } - - FileIndexResult selection = - new BitmapIndexResult(() -> RoaringBitmap32.bitmapOfRange(0, file.rowCount())); - if (deletionVector instanceof BitmapDeletionVector) { - RoaringBitmap32 deletion = ((BitmapDeletionVector) deletionVector).get(); - selection = ((BitmapIndexResult) selection).andNot(deletion); - } - - // for now, limit can not work with other predicates. - if (isNullOrEmpty(dataFilter) && topN == null && limit != null) { - return ((BitmapIndexResult) selection).limit(limit); + if (isNullOrEmpty(dataFilter) && topN == null) { + if (limit == null) { + return FileIndexResult.REMAIN; + } else { + // limit can not work with other predicates. + return createBaseSelection(file, dv).limit(limit); + } } try (FileIndexPredicate predicate = @@ -74,6 +67,7 @@ public class FileIndexEvaluator { return FileIndexResult.REMAIN; } + BitmapIndexResult selection = createBaseSelection(file, dv); FileIndexResult result; if (!isNullOrEmpty(dataFilter)) { Predicate filter = PredicateBuilder.and(dataFilter.toArray(new Predicate[0])); @@ -99,6 +93,17 @@ public class FileIndexEvaluator { } } + private static BitmapIndexResult createBaseSelection( + DataFileMeta file, @Nullable DeletionVector dv) { + BitmapIndexResult selection = + new BitmapIndexResult(() -> RoaringBitmap32.bitmapOfRange(0, file.rowCount())); + if (dv instanceof BitmapDeletionVector) { + RoaringBitmap32 deletion = ((BitmapDeletionVector) dv).get(); + selection = selection.andNot(deletion); + } + return selection; + } + @Nullable private static FileIndexPredicate createFileIndexPredicate( FileIO fileIO,