Have a specific use case and not too sure of the best approach.
So the current approach right now is that I'm iterating over a collection of objects (closeable iterator) and mapping them in a hashmap (dealing with conflicts appropriately, comparing by an object's date property).
I'm looking for a parallel approach to speed things up and the initial idea was to use Java 8 streams with parallel and forEach utilizing a concurrent hashmap to enable concurrency. The main bottleneck with this approach seems to be the concurrent hashmap and there are no improvements with this approach at adding concurrency.
My idea right now is to map into multiple hashmaps in parallel. Then reduce into a single hashmap dealing with conflicts appropriately. Wondering how I would implement such an approach in Java using Streams. I know there are built in map and reduce operations but not sure about the approach of collecting multiple hashmaps (perform the operation and add to a set?).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…