session InspectionObligationsV2 (step 5) putAll batch size 200

This commit is contained in:
ialbert 2024-08-02 17:54:32 +03:00
parent 4c0dd1739b
commit b74ebc3b0e
3 changed files with 20 additions and 1 deletions

View file

@ -285,7 +285,7 @@ public class InspectionObligationsV2 implements ISessionStage {
}
}
}
registryImdg.putAll(rgssToStore);
registryImdg.putAll(rgssToStore, 200);
planBalanceCalc.stageRevision2(sessionId);

View file

@ -2,6 +2,7 @@ package ru.spcex.platform.imdg.iml.hazelcast.adapter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -107,6 +108,22 @@ public class ImdgHazelcast<T extends SpcexObjectBase> implements Imdg<T> {
map.putAll(m);
}
@Override
public void putAll(Map<Long, T> m, int batchSize) {
if (batchSize <= 0) throw new IllegalArgumentException("illegal batch size " + batchSize);
Map<Long, T> batch = new HashMap<>(batchSize);
for (Map.Entry<Long, T> entry : m.entrySet()) {
batch.put(entry.getKey(), entry.getValue());
if (batch.size() >= batchSize) {
map.putAll(batch);
batch.clear();
}
}
if (!batch.isEmpty()) {
map.putAll(batch);
}
}
@Override
public void update(T paramT) {
map.put(paramT.getId(), paramT);

View file

@ -21,6 +21,8 @@ public interface Imdg<T extends SpcexObjectBase> {
default void putAll(Map<Long, T> batch) {throw new UnsupportedOperationException("not implemented update");}
default void putAll(Map<Long, T> batch, int batchSize) {throw new UnsupportedOperationException("not implemented update");}
default void update(T paramT) {
throw new UnsupportedOperationException("not implemented update");
}