Jackie-Jiang commented on code in PR #9453:
URL: https://github.com/apache/pinot/pull/9453#discussion_r978447120
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/BitSlicedRangeIndexReader.java:
##########
@@ -122,35 +157,39 @@ public ImmutableRoaringBitmap
getPartiallyMatchingDocIds(double min, double max)
}
private ImmutableRoaringBitmap queryRangeBitmap(long min, long max, long
columnMax) {
- RangeBitmap rangeBitmap = mapRangeBitmap();
- if (Long.compareUnsigned(max, columnMax) < 0) {
- if (Long.compareUnsigned(min, 0) > 0) {
- return rangeBitmap.between(min, max).toMutableRoaringBitmap();
- }
- return rangeBitmap.lte(max).toMutableRoaringBitmap();
- } else {
- if (Long.compareUnsigned(min, 0) > 0) {
- return rangeBitmap.gte(min).toMutableRoaringBitmap();
- }
+ // Compare unsigned
+ boolean lowerUnbounded = min + Long.MIN_VALUE <= Long.MIN_VALUE;
+ boolean upperUnbounded = max + Long.MIN_VALUE >= columnMax +
Long.MIN_VALUE;
+ if (lowerUnbounded && upperUnbounded) {
MutableRoaringBitmap all = new MutableRoaringBitmap();
- all.add(0, _numDocs);
+ all.add(0L, _numDocs);
return all;
}
+ RangeBitmap rangeBitmap = mapRangeBitmap();
+ if (lowerUnbounded) {
+ return rangeBitmap.lte(max).toMutableRoaringBitmap();
+ }
+ if (upperUnbounded) {
+ return rangeBitmap.gte(min).toMutableRoaringBitmap();
+ }
+ return rangeBitmap.between(min, max).toMutableRoaringBitmap();
Review Comment:
It will improve the case of full match, where we don't need to read the
range bitmap. But agree we can focus on just the bugfix in this PR
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/creator/BitSlicedIndexCreatorTest.java:
##########
@@ -250,24 +276,37 @@ private void testDouble(Dataset<double[]> dataset)
File rangeIndexFile = new File(INDEX_DIR, metadata.getColumnName() +
BITMAP_RANGE_INDEX_FILE_EXTENSION);
try (PinotDataBuffer dataBuffer =
PinotDataBuffer.mapReadOnlyBigEndianFile(rangeIndexFile)) {
BitSlicedRangeIndexReader reader = new
BitSlicedRangeIndexReader(dataBuffer, metadata);
- double prev = Double.NEGATIVE_INFINITY;
- for (double quantile : dataset.quantiles()) {
- ImmutableRoaringBitmap reference = dataset.scan(prev, quantile);
- ImmutableRoaringBitmap result = reader.getMatchingDocIds(prev,
quantile);
- int resultCount = reader.getNumMatchingDocs(prev, quantile);
- assertEquals(result, reference);
- assertEquals(resultCount, result == null ? 0 :
result.getCardinality());
+ double[] quantiles = dataset.quantiles();
+ // TODO: RangeBitmap has a bug in version 0.9.28 which gives wrong
result computing between for 2 doubles with
+ // different sign. The bug is tracked here:
https://github.com/RoaringBitmap/RoaringBitmap/issues/586.
+ // Uncomment this line after the bug is fixed.
+// double prev = quantiles[0] - 1;
Review Comment:
Sounds good
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]