findepi commented on code in PR #10691: URL: https://github.com/apache/iceberg/pull/10691#discussion_r1686847688
########## core/src/test/java/org/apache/iceberg/util/TestParallelIterable.java: ########## @@ -133,6 +140,47 @@ public CloseableIterator<Integer> iterator() { .untilAsserted(() -> assertThat(queue).as("Queue is not empty after cleaning").isEmpty()); } + @Test + public void limitQueueSize() throws IOException, IllegalAccessException, NoSuchFieldException { + + List<Iterable<Integer>> iterables = + ImmutableList.of( + () -> IntStream.range(0, 100).iterator(), + () -> IntStream.range(0, 100).iterator(), + () -> IntStream.range(0, 100).iterator()); + + Multiset<Integer> expectedValues = + IntStream.range(0, 100) + .boxed() + .flatMap(i -> Stream.of(i, i, i)) + .collect(ImmutableMultiset.toImmutableMultiset()); + + int maxQueueSize = 20; + ExecutorService executor = Executors.newCachedThreadPool(); + ParallelIterable<Integer> parallelIterable = + new ParallelIterable<>(iterables, executor, maxQueueSize); + CloseableIterator<Integer> iterator = parallelIterable.iterator(); + Field queueField = iterator.getClass().getDeclaredField("queue"); + queueField.setAccessible(true); + ConcurrentLinkedQueue<?> queue = (ConcurrentLinkedQueue<?>) queueField.get(iterator); + + Multiset<Integer> actualValues = HashMultiset.create(); + + while (iterator.hasNext()) { Review Comment: at the end we compare the values read from the iterator against the expected values. so the iterator cannot be empty, and so the check indeed is checked at least once -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org