-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup batching in the AbstractPolicy instead of a seperate Policy.
- Loading branch information
Showing
11 changed files
with
282 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 0 additions & 80 deletions
80
src/main/java/com/github/mmolimar/kafka/connect/fs/policy/SimpleBatchPolicy.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/github/mmolimar/kafka/connect/fs/util/BatchIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.github.mmolimar.kafka.connect.fs.util; | ||
|
||
import java.util.Iterator; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class BatchIterator { | ||
private static final Logger log = LoggerFactory.getLogger(BatchIterator.class); | ||
|
||
public static <T> Iterator<T> chunkIterator(Iterator<T> iterator, long elementsPerBatch) { | ||
return new Iterator<T>() { | ||
private long count = 0; | ||
|
||
@Override | ||
public boolean hasNext() { | ||
log.debug("Current index is {}. Batch size is {}.", count, elementsPerBatch); | ||
return (count < elementsPerBatch) && iterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public T next() { | ||
T next = iterator.next(); | ||
count++; | ||
return next; | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.