dweiss commented on code in PR #15306:
URL: https://github.com/apache/lucene/pull/15306#discussion_r2414858700
##########
lucene/core/src/test/org/apache/lucene/util/TestPriorityQueue.java:
##########
@@ -208,57 +209,48 @@ public void testAddAllDoesNotFitIntoQueue() {
() -> pq.addAll(list));
}
+ /** Randomly add and remove elements, comparing against the reference
java.util.PriorityQueue. */
public void testRemovalsAndInsertions() {
- Random random = random();
- int numDocsInPQ = TestUtil.nextInt(random, 1, 100);
- IntegerQueue pq = new IntegerQueue(numDocsInPQ);
- Integer lastLeast = null;
-
- // Basic insertion of new content
- ArrayList<Integer> sds = new ArrayList<>(numDocsInPQ);
- for (int i = 0; i < numDocsInPQ * 10; i++) {
- Integer newEntry = Math.abs(random.nextInt());
- sds.add(newEntry);
- Integer evicted = pq.insertWithOverflow(newEntry);
- pq.checkValidity();
- if (evicted != null) {
- assertTrue(sds.remove(evicted));
- if (evicted != newEntry) {
- assertSame(evicted, lastLeast);
+ int maxElement = RandomNumbers.randomIntBetween(random(), 1, 10_000);
+ int size = maxElement / 2 + 1;
+
+ var reference = new java.util.PriorityQueue<Integer>();
+ var pq = new IntegerQueue(size);
+
+ Random localRandom = new Xoroshiro128PlusRandom(random().nextLong());
+
+ // Lucene's PriorityQueue.remove uses reference equality, not .equals to
determine which
+ // elements
+ // to remove (!).
+ HashMap<Integer, Integer> ints = new HashMap<>();
Review Comment:
https://github.com/apache/lucene/issues/15309
--
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]