Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class JavaFiddle
  2. {
  3. public static void main(String[] args)
  4. {
  5. System.out.println("HelloWorld!");
  6. List<Long> replicationErrorIds = new ArrayList<>();
  7. for(int i = 0; i < 100; i++) {
  8. replicationErrorIds.add(i);
  9. }
  10. System.out.println(this.chuckReplicationErrorIds(replicationErrorIds,10));
  11.  
  12. }
  13.  
  14. private List<List<Long>> chuckReplicationErrorIds(List<Long> replicationErrorIds, int chunkSize) {
  15. int numOfChunks = (int)Math.ceil((double)replicationErrorIds.size() / chunkSize);
  16. List<List<Long>> chunks = new ArrayList<>();
  17.  
  18. for(int i = 0; i < numOfChunks; ++i) {
  19. int start = i * chunkSize;
  20. int length = Math.min(replicationErrorIds.size() - start, chunkSize);
  21.  
  22. chunks.add(replicationErrorIds.subList(start, start + length - 1));
  23. }
  24.  
  25. return chunks;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement