richardstartin commented on a change in pull request #7435: URL: https://github.com/apache/pinot/pull/7435#discussion_r710459841
########## File path: pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/creator/RangeIndexCreatorTest.java ########## @@ -242,141 +242,352 @@ private void addDataToIndexer(DataType dataType, int numDocs, int numValuesPerEn } } - private void checkValueForDocId(DataType dataType, Number[] values, Number[] rangeStartArray, int rangeId, int docId, + private void verifyRangesForDataType(DataType dataType, Object values, Object ranges, int numValuesPerMVEntry, + RangeIndexReader<ImmutableRoaringBitmap> rangeIndexReader) { + switch (dataType) { + case INT: { + // single bucket ranges + int rangeId = 0; + for (int[] range : (int[][]) ranges) { + assertNull(rangeIndexReader.getMatchingDocIds(range[0], range[1]), + "range index can't guarantee match within a single range"); + ImmutableRoaringBitmap partialMatches = rangeIndexReader.getPartiallyMatchingDocIds(range[0], range[1]); + assertNotNull(partialMatches, "partial matches for single range must not be null"); + for (int docId : partialMatches.toArray()) { + checkValueForDocId(dataType, values, ranges, rangeId, docId, numValuesPerMVEntry); + } + ++rangeId; + } + // multi bucket ranges + int[] lowerPartialRange = ((int[][]) ranges)[0]; + int[] coveredRange = ((int[][]) ranges)[1]; + int[] upperPartialRange = ((int[][]) ranges)[2]; + ImmutableRoaringBitmap matches = rangeIndexReader.getMatchingDocIds(lowerPartialRange[0], upperPartialRange[1]); + assertNotNull(matches, "matches for covered range must not be null"); + for (int docId : matches.toArray()) { + checkValueForDocId(dataType, values, ranges, 1, docId, numValuesPerMVEntry); + } + assertEquals(matches, rangeIndexReader.getPartiallyMatchingDocIds(coveredRange[0], coveredRange[1])); + // partial matches must be the combination of the two edge buckets + ImmutableRoaringBitmap partialMatches = rangeIndexReader.getPartiallyMatchingDocIds( + lowerPartialRange[0], upperPartialRange[1]); + assertNotNull(partialMatches, "partial matches for single range must not be null"); + assertEquals(ImmutableRoaringBitmap.or( + rangeIndexReader.getPartiallyMatchingDocIds(lowerPartialRange[0], lowerPartialRange[1]), + rangeIndexReader.getPartiallyMatchingDocIds(upperPartialRange[0], upperPartialRange[1])), partialMatches); + // edge cases + assertEquals(((int[]) values).length, numValuesPerMVEntry Review comment: This API doesn't exist for `Random.nextLong()`. The `Random` is seeded for determinism, as is good practice in testing (this is not a fuzz test, this is not property based testing) so this is not a problem. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org