private final Map<Integer, Long> sujetCount;
...
public void updateStatistical(CompactTriple t){
if (t.hasAnyUnknownKey() || t.isSujetVariable() || t.isPredicatVariable()|| t.isObjetVariable())
throw new IllegalArgumentException("Le paramètre t doit être composé seulement de littéraux connus");
sujetCount.merge(t.sujet(), 1L, Long::sum);
...
private boolean addTriple(CompactTriple triple) {
AtomicBoolean wasAdded = new AtomicBoolean();
CompletableFuture.allOf(
CompletableFuture.runAsync(() -> wasAdded.set(spo.add(triple.toT3(OrdreT3.SPO)))),
CompletableFuture.runAsync(() -> sop.add(triple.toT3(OrdreT3.SOP))),
CompletableFuture.runAsync(() -> pso.add(triple.toT3(OrdreT3.PSO))),
CompletableFuture.runAsync(() -> pos.add(triple.toT3(OrdreT3.POS))),
CompletableFuture.runAsync(() -> osp.add(triple.toT3(OrdreT3.OSP))),
// CompletableFuture.runAsync(() -> ops.add(triple.toT3(OrdreT3.OPS))),
CompletableFuture.runAsync(() -> statisticalStore.updateStatistical(triple))
).join();
return wasAdded.get();
}
Is there any problem with this implementation and use of CompletableFuture.runAsync()?
Doing it in parallel gives me a performance gain, even though it's just for one Add (i am doing it 100k times).