我使用下面的代码从文件名中插入日志。日志文件包含1000 s行。新的行被添加了几秒钟。但是,当我运行这段代码时,生成的表只有15-20行。
Rows dfpadunit = new TableDataInsertAllRequest.Rows();
List<Rows> dfpadunits = new ArrayList<Rows>();
TableDataInsertAllRequest content = new TableDataInsertAllRequest();
content.setIgnoreUnknownValues(true);
content.setSkipInvalidRows(true);
reader = new BufferedReader(new FileReader( FILENAME ) );
while( running ) {
while ((line = reader.readLine()) != null) {
TableRow aRow = new TableRow();
aRow.set("RAW_DATA", line);
String time = BigqueryUtils.getCurrentYYMMDDHHMM();
aRow.set("TIME", time);
dfpadunit.setJson(aRow);
dfpadunit.setInsertId(time);
dfpadunits.add(dfpadunit);
}
if(dfpadunits.size() > 0) {
content.setRows(dfpadunits);
TableDataInsertAllResponse response = BQUtils.run(PRE_STG_DATA_SET_ID, DESTINATION_TABLE, content);
dfpadunits.clear();
if(response != null) {
formatTable();
}
}
System.out.println("About to sleep");
Thread.sleep( 1000 * 60);
}发布于 2017-04-06 14:38:03
insert id用作去重复键。您使用当前时间(以分钟为单位)作为插入id。这意味着在同一分钟内的所有插入都使用相同的去重复键,因此只有最后一个保留下来。您将希望将insert id保留为空,或者使用随机生成的id作为insert ID。
https://stackoverflow.com/questions/43147944
复制相似问题