0

I have to update n records. Due to some limitations, I cannot update more than k records in one go. So I want to do n/k iterations serially, and in each iteration update k records.

Is there a generic 3rd party library for splitting work load and doing it in batches (like how I want)? Almost all my googling pointed me to libraries which can parallelize work, but here I want to serialize it in batches.

I can own library, but I wanted to know if there was a 3rd party library that has some additionally capabilities like, ability to do some pre-work before and/or post-work after, the work, and doing something before and after each batch.

smc
  • 710
  • 1
  • 9
  • 26
  • There are plenty of batch libraries. – Kayaman Apr 09 '18 at 09:03
  • Can you point me to one? As I noted, all batch libraries I was split work across various threads. I dont know if my requirement comes under 'Partitioning' or 'batch processing'. – smc Apr 09 '18 at 09:14
  • I'd be surprised if you couldn't configure them for single threaded operation. It's a pretty basic requirement to allow both single and multithreaded batching. – Kayaman Apr 09 '18 at 09:17
  • I think these batching libraries attempt to split work across many threads, but not within one thread. Please correct me if I am wrong. – smc Apr 09 '18 at 09:20
  • Related: [Partition a Java 8 Stream](https://stackoverflow.com/q/32434592/1542723) – Ferrybig Apr 09 '18 at 09:22
  • You seem to assume that a library works in a single preset way and you can't configure it to behave differently. – Kayaman Apr 09 '18 at 09:23
  • You want to update `k` records in one go but just in a single thread? What do you then mean by in one go? Do you want to make one single request/db call which updates those `k` records? – Simon Apr 09 '18 at 09:56
  • @Simon yes, one single db request updating k records. – smc Apr 09 '18 at 10:34
  • http://www.baeldung.com/java-list-split (lacks the pre/post processing hooks but shows several ways to partition a list) – Simon Apr 09 '18 at 11:55

0 Answers0