将batch提交改成每200行提交一次,每提交一次sleep一次,用com.google.common.collect.Lists#partition 实现 public…
- User
将batch提交改成每200行提交一次,每提交一次sleep一次,用com.google.common.collect.Lists#partition 实现
codepublic void run() { Object[][] args = new Object[preIds.size()][2]; int i = 0; for (Long pre_action_id : preIds) { args[i][0] = pre_action_id; args[i++][1] = sub_id; } try { runner.batch("insert into " + target_table + "(pre_id,sub_id) values(?,?)", args); } catch (Exception e) { e.printStackTrace(); System.err.println("fail " + sub_id + " " + preIds.toString()); } } - Assistant
您希望将批处理提交改为每200行提交一次,并在每次提交后休眠一下,可以使用
Guava库中的Lists.partition方法来实现。下面是修改后的代码示例:java - User
每个batch提交的耗时,打印一下
- Assistant
为了记录每个批处理提交的耗时,可以在批处理执行前后添加时间戳,然后计算并打印出每次提交所耗的时间。以下是修改后的代码示例:
java
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.