maedhroz commented on code in PR #2487:
URL: https://github.com/apache/cassandra/pull/2487#discussion_r1262963910
##########
test/unit/org/apache/cassandra/index/sai/disk/v1/bbtree/BlockBalancedTreeReaderTest.java:
##########
@@ -222,6 +231,55 @@ public void
testResourcesReleaseWhenQueryDoesntMatchAnything() throws Exception
assertNull(intersection);
}
+ @Test
+ public void testConcurrentIntersectionsOnSameReader() throws Exception
+ {
+ int numRows = 1000;
+
+ final BlockBalancedTreeRamBuffer buffer = new
BlockBalancedTreeRamBuffer(Integer.BYTES);
+
+ byte[] scratch = new byte[4];
+ for (int docID = 0; docID < numRows; docID++)
+ {
+ NumericUtils.intToSortableBytes(docID, scratch, 0);
+ buffer.add(docID, 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++)
+ {
+ results.add(executor.submit(() -> assertIntersection(reader,
expression)));
+ }
+ FBUtilities.waitOnFutures(results);
+ executor.shutdown();
+ }
+
+ private void assertIntersection(BlockBalancedTreeReader reader, Expression
expression)
Review Comment:
nit: I might clean this up to be like `assertRange()` or something where we
pass 445 and 555 as inclusive and exclusive bounds, etc.
(can fix on commit)
--
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]