BAEL-5924 Java 8 Stream with Batch Processing Support (#13366)

This commit is contained in:
alemoles 2023-01-30 14:19:57 -03:00 committed by GitHub
parent aab7f72429
commit b40a061969
1 changed files with 3 additions and 3 deletions

View File

@ -14,20 +14,20 @@ public class CustomBatchIterator<T> implements Iterator<List<T>> {
private List<T> currentBatch;
private final Iterator<T> iterator;
public CustomBatchIterator(Iterator<T> sourceIterator, int batchSize) {
private CustomBatchIterator(Iterator<T> sourceIterator, int batchSize) {
this.batchSize = batchSize;
this.iterator = sourceIterator;
}
@Override
public List<T> next() {
prepareNextBatch();
return currentBatch;
}
@Override
public boolean hasNext() {
prepareNextBatch();
return currentBatch != null && !currentBatch.isEmpty();
return iterator.hasNext();
}
public static <T> Stream<List<T>> batchStreamOf(Stream<T> stream, int batchSize) {