maedhroz commented on code in PR #2487:
URL: https://github.com/apache/cassandra/pull/2487#discussion_r1264075164


##########
test/unit/org/apache/cassandra/index/sai/disk/v1/bbtree/BlockBalancedTreeReaderTest.java:
##########
@@ -239,38 +236,39 @@ public void testConcurrentIntersectionsOnSameReader() 
throws Exception
         final BlockBalancedTreeRamBuffer buffer = new 
BlockBalancedTreeRamBuffer(Integer.BYTES);
 
         byte[] scratch = new byte[4];
-        for (int docID = 0; docID < numRows; docID++)
+        for (int rowID = 0; rowID < numRows; rowID++)
         {
-            NumericUtils.intToSortableBytes(docID, scratch, 0);
-            buffer.add(docID, scratch);
+            NumericUtils.intToSortableBytes(rowID, scratch, 0);
+            buffer.add(rowID, scratch);
         }
 
-        final BlockBalancedTreeReader reader = finishAndOpenReader(4, buffer);
-
-        Expression expression = new Expression(indexContext);
-        expression.add(Operator.GT, Int32Type.instance.decompose(444));
-        expression.add(Operator.LT, Int32Type.instance.decompose(555));
-
-        int concurrency = 100;
-
-        ExecutorService executor = Executors.newFixedThreadPool(concurrency);
-        List<Future<?>> results = new ArrayList<>();
-        for (int thread = 0; thread < concurrency; thread++)
+        try (BlockBalancedTreeReader reader = finishAndOpenReader(4, buffer))
         {
-            results.add(executor.submit(() -> assertIntersection(reader, 
expression)));
+            int concurrency = 100;
+
+            ExecutorService executor = 
Executors.newFixedThreadPool(concurrency);
+            List<Future<?>> results = new ArrayList<>();
+            for (int thread = 0; thread < concurrency; thread++)
+            {
+                results.add(executor.submit(() -> assertRange(reader, 445, 
555)));
+            }
+            FBUtilities.waitOnFutures(results);
+            executor.shutdown();
         }
-        FBUtilities.waitOnFutures(results);
-        executor.shutdown();
     }
 
-    private void assertIntersection(BlockBalancedTreeReader reader, Expression 
expression)
+    private void assertRange(BlockBalancedTreeReader reader, long lowerBound, 
long upperBound)
     {
+        Expression expression = new Expression(indexContext);
+        expression.add(Operator.GT, Int32Type.instance.decompose(444));
+        expression.add(Operator.LT, Int32Type.instance.decompose(555));
+
         try
         {
             PostingList intersection = performIntersection(reader, 
BlockBalancedTreeQueries.balancedTreeQueryFrom(expression, 4));
             assertNotNull(intersection);
             assertEquals(110, intersection.size());

Review Comment:
   nit: `upperBound - lowerBound` instead of hard-coding 110?



-- 
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]

Reply via email to