报错:Cause: com.kingbase8.util.KSQLException: 错误: 堆栈深度超过限制 Hint: 在确定了平台的堆栈深度限制是足够大后,增加配置参数 "max_stack_depth"的值(当前值为2048kB).; 错误: 堆栈深度超过限制 Hint: 在确定了平台的堆栈深度限制是足够大后,增加配置参数 "max_stack_depth"的值(当前值为2048kB).; nested exception is com.kingbase8.util.KSQLException: 错误: 堆栈深度超过限制 Hint: 在确定了平台的堆栈深度限制是足够大后,增加配置参数 "max_stack_depth"的值(当前值为2048kB).]
经过以下改进仍没能解决:
java
List<String> sampleInfoIds = sampleInfoList.parallelStream()
.map(BaseEntity::getId).collect(Collectors.toList());//sampleInfoIds过大
List<String> subList1 = sampleInfoIds.subList(0, sampleInfoIds.size() / 2);
List<String> subList2 = sampleInfoIds.subList(sampleInfoIds.size() / 2, sampleInfoIds.size()-1);
List<SampleInfoDTO> sampleInfoDTOList = sampleInfoMapper.getSampleInfoDTOByIds(subList1);
List<SampleInfoDTO> sampleInfoDTOList1 =sampleInfoMapper.getSampleInfoDTOByIds(subList2);
sampleInfoDTOList.addAll(sampleInfoDTOList1);
java
List<String> sampleInfoIds = sampleInfoList.parallelStream()
.map(BaseEntity::getId).collect(Collectors.toList());
int batch=7000;
int c=(int) Math.ceil((sampleInfoIds.size()*1.0)/batch);
List<SampleInfoDTO> sampleInfoDTOList=new ArrayList<>();
List<CompletableFuture> completableFutures=new ArrayList<>();
for (int i=0;i<c;i++){
int fromIndex=i*batch;
int endIndex=(i+1)*batch-1;
List<String> ids=sampleInfoIds.subList(fromIndex,Math.min(endIndex, sampleInfoIds.size()-1));
CompletableFuture<List<SampleInfoDTO>> future = CompletableFuture.supplyAsync(() -> {
return sampleInfoMapper.getSampleInfoDTOByIds(ids);
}, executor);
completableFutures.add(future);
}
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0])).join();
for (CompletableFuture future : completableFutures) {
try {
sampleInfoDTOList.addAll((List<SampleInfoDTO>) future.get());
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}