int limit = 1000;
int total = list.size();
int batch = (total + limit - 1) / limit;
AtomicInteger fileUpdates = new AtomicInteger(0);
int dbUpdates = IntStream.range(0, batch)
.map(p -> p * limit).parallel()
.mapToObj(start -> list.stream().skip(start).limit(limit).collect(Collectors.toList()))
.filter(list1 -> !list1.isEmpty())
.map(subList -> {
fileUpdates.addAndGet(service.batchDeleteFile(subList));
if (target.equalsIgnoreCase("jpg")) {
return DBDAO.deleteJpg(subList);
}
else {
return DBDAO.deleteOther(subList);
}
})
.reduce((a,s) -> {s += a; return s;})
.orElse(0);
int batchSize = 1000;
int num = 0;
int num2 = 0;
int max = list.size();
for(int i=0; i < max; i += batchSize) {
int ceil = i + batchSize;
int upper = Math.min( ceil, max );
List<String> subList = list.subList(i, upper);
num += service.batchDeleteFile(subList);
if (target.equalsIgnoreCase("jpg")) {
num2 += DBDAO.deleteJpgOss(subList);
}
else {
num2 += DBDAO.deleteOtherOss(subList);
}
}