rdsr commented on a change in pull request #45: Lazily submit tasks in
ParallelIterable and add cancellation.
URL: https://github.com/apache/incubator-iceberg/pull/45#discussion_r240901429
##########
File path: core/src/main/java/com/netflix/iceberg/util/ParallelIterable.java
##########
@@ -19,73 +19,124 @@
package com.netflix.iceberg.util;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.netflix.iceberg.io.CloseableGroup;
+import java.io.Closeable;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-public class ParallelIterable<T> implements Iterable<T> {
+public class ParallelIterable<T> extends CloseableGroup implements Iterable<T>
{
private final Iterable<Iterable<T>> iterables;
- private final ExecutorService trackingPool;
private final ExecutorService workerPool;
public ParallelIterable(Iterable<Iterable<T>> iterables,
- ExecutorService trackingPool,
ExecutorService workerPool) {
this.iterables = iterables;
- this.trackingPool = trackingPool;
this.workerPool = workerPool;
}
@Override
public Iterator<T> iterator() {
- return new ParallelIterator<>(iterables, trackingPool, workerPool);
+ ParallelIterator<T> iter = new ParallelIterator<>(iterables, workerPool);
+ addCloseable(iter);
+ return iter;
}
- private static class ParallelIterator<T> implements Iterator<T> {
+ private static class ParallelIterator<T> implements Iterator<T>, Closeable {
Review comment:
I believe manual task tracking is required for cancellation of futures when
the iterator is closed. Cancellation doesn't seem possible in this approach
though, isn't?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services