我使用google bigquery API将数据插入bigquery
public void upload(Collection<Bucket> buckets){
log.finer("Uploading " + buckets.size() + " buckets to bigquery");
List<Rows> rows=new ArrayList<Rows>();
for ( Bucket bucket : buckets) {
TableRow row=new TableRow();
row.set("uploaded",System.currentTimeMillis() / 1000f);
row.set("codepoint",bucket.getKey().getCodepoint());
row.set("namespace",bucket.getKey().getNamespace());
row.set("kind",bucket.getKey().getKind());
row.set("op",bucket.getKey().getOp());
row.set("query",bucket.getKey().getQuery());
row.set("time",bucket.getKey().getTime() / 1000f);
row.set("reads",bucket.getReads());
row.set("writes",bucket.getWrites());
TableDataInsertAllRequest.Rows rowWrapper=new TableDataInsertAllRequest.Rows();
rowWrapper.setJson(row);
rows.add(rowWrapper);
}
TableDataInsertAllRequest request=new
TableDataInsertAllRequest().setRows(rows);
String tableId=tablePicker.pick();
try {
TableDataInsertAllResponse response=bigquery.tabledata().insertAll(insightDataset.projectId(),insightDataset.datasetId(),tableId,request).execute();
if (response.getInsertErrors() != null && !response.getInsertErrors().isEmpty()) {
throw new RuntimeException("There were errors! " + response.getInsertErrors());
}
}
catch ( IOException e) {
throw new RuntimeException(e);
}
}
我的问题:
我使用2服务器调用函数同时插入bigquery,同一帐户bigquery。
示例:
服务器A:有500行
服务器B:有400行
如果插入google bigquery 900行
,那是对的但是当我登记google bigquery有1300行时。
当我使用1台服务器进行测试时,它会向右插入(服务器A为500行,服务器B为400行)。
你能帮我解决这个问题吗?
答案 0 :(得分:0)