ArnavBalyan commented on code in PR #6178:
URL: https://github.com/apache/paimon/pull/6178#discussion_r2315571404
##########
paimon-common/src/main/java/org/apache/paimon/fileindex/rangebitmap/BitSliceIndexBitmap.java:
##########
@@ -178,24 +183,34 @@ public RoaringBitmap32 topK(int k, @Nullable
RoaringBitmap32 foundSet) {
e = RoaringBitmap32.andNot(e, getSlice(i));
} else {
e = RoaringBitmap32.and(e, getSlice(i));
- break;
+ if (!allowDuplicates) {
+ break;
+ }
+ // If allowDuplicates, continue to include all rows with the
same value
}
}
- // only k results should be returned
+ // Return all results if allowDuplicates, otherwise limit to k
RoaringBitmap32 f = RoaringBitmap32.or(g, e);
- long n = f.getCardinality() - k;
- if (n > 0) {
- Iterator<Integer> iterator = e.iterator();
- while (iterator.hasNext() && n > 0) {
- f.remove(iterator.next());
- n--;
+ if (!allowDuplicates) {
+ 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;
}
public RoaringBitmap32 bottomK(int k, @Nullable RoaringBitmap32 foundSet) {
+ return bottomK(k, foundSet, false);
+ }
+
+ public RoaringBitmap32 bottomK(
+ int k, @Nullable RoaringBitmap32 foundSet, boolean
allowDuplicates) {
Review Comment:
updated
##########
paimon-common/src/main/java/org/apache/paimon/fileindex/rangebitmap/BitSliceIndexBitmap.java:
##########
@@ -178,24 +183,34 @@ public RoaringBitmap32 topK(int k, @Nullable
RoaringBitmap32 foundSet) {
e = RoaringBitmap32.andNot(e, getSlice(i));
} else {
e = RoaringBitmap32.and(e, getSlice(i));
- break;
+ if (!allowDuplicates) {
+ break;
+ }
+ // If allowDuplicates, continue to include all rows with the
same value
}
}
- // only k results should be returned
+ // Return all results if allowDuplicates, otherwise limit to k
RoaringBitmap32 f = RoaringBitmap32.or(g, e);
- long n = f.getCardinality() - k;
- if (n > 0) {
- Iterator<Integer> iterator = e.iterator();
- while (iterator.hasNext() && n > 0) {
- f.remove(iterator.next());
- n--;
+ if (!allowDuplicates) {
+ 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;
}
public RoaringBitmap32 bottomK(int k, @Nullable RoaringBitmap32 foundSet) {
+ return bottomK(k, foundSet, false);
Review Comment:
done
##########
paimon-common/src/main/java/org/apache/paimon/fileindex/rangebitmap/RangeBitmap.java:
##########
@@ -281,13 +281,36 @@ private BitSliceIndexBitmap getBitSliceIndexBitmap() {
public RoaringBitmap32 topK(
int k, SortValue.NullOrdering nullOrdering, @Nullable
RoaringBitmap32 foundSet) {
- return fillNulls(k, nullOrdering, foundSet, (l, r) ->
getBitSliceIndexBitmap().topK(l, r));
+ return topK(k, nullOrdering, foundSet, false);
Review Comment:
removed
--
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]