Tan-JiaLiang commented on code in PR #6178:
URL: https://github.com/apache/paimon/pull/6178#discussion_r2315663679
##########
paimon-common/src/main/java/org/apache/paimon/fileindex/rangebitmap/BitSliceIndexBitmap.java:
##########
@@ -183,16 +178,16 @@ public RoaringBitmap32 topK(
e = RoaringBitmap32.andNot(e, getSlice(i));
} else {
e = RoaringBitmap32.and(e, getSlice(i));
- if (!allowDuplicates) {
+ if (strict) {
break;
}
- // If allowDuplicates, continue to include all rows with the
same value
+ // If not strict, continue to include all rows with the same
value
}
}
- // Return all results if allowDuplicates, otherwise limit to k
+ // Return all results if not strict, otherwise limit to k
RoaringBitmap32 f = RoaringBitmap32.or(g, e);
- if (!allowDuplicates) {
+ if (strict) {
Review Comment:
What about this?
```java
RoaringBitmap32 f = RoaringBitmap32.or(g, e);
if (!strict) {
return f;
}
long n = f.getCardinality() - k;
if (n > 0) {
Iterator<Integer> iterator = e.iterator();
while (iterator.hasNext() && n > 0) {
f.remove(iterator.next());
n--;
}
}
return f;
```
##########
paimon-common/src/main/java/org/apache/paimon/fileindex/rangebitmap/RangeBitmapFileIndex.java:
##########
@@ -157,10 +157,10 @@ public FileIndexResult visitGreaterOrEqual(FieldRef
fieldRef, Object literal) {
public FileIndexResult visitTopN(TopN topN, FileIndexResult result) {
List<SortValue> orders = topN.orders();
- // If multiple columns, use first column with allowDuplicates=true
- boolean useFirstColumn = orders.size() > 1;
+ // If multiple columns, use first column with strict=false (allow
duplicates)
+ boolean isMultiColumn = orders.size() > 1;
SortValue sort = orders.get(0); // Always use first column
- boolean allowDuplicates = useFirstColumn;
+ boolean strict = !isMultiColumn;
Review Comment:
I think is ok to just
```java
boolean strict = orders.size() == 1;
```
##########
paimon-common/src/main/java/org/apache/paimon/fileindex/rangebitmap/BitSliceIndexBitmap.java:
##########
@@ -183,16 +178,16 @@ public RoaringBitmap32 topK(
e = RoaringBitmap32.andNot(e, getSlice(i));
} else {
e = RoaringBitmap32.and(e, getSlice(i));
- if (!allowDuplicates) {
+ if (strict) {
Review Comment:
I think here is ok to use `break` directly. Because we operate the entireĀ
bit for each time.
--
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]