2017-03-31 31 views
0

我正在使用以下代码从FILENAME插入日志。日志文件包含1000行。随着新的线路增加了几秒钟。但是,当我运行此代码时,生成的表格只有15-20个奇数行。Bigquery InsertAll不按预期工作

 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); 
     } 
+0

如何在BigQuery中检查表的大小? –

+0

一个简单的选择计数(*)。我也在一天后尝试了这一点,它仍然是一样的。 –

+0

插入用作重复数据删除键。您将以分钟为单位的当前时间用作插入ID。这意味着在同一分钟内的所有插入使用相同的重复数据删除键 - 只有最后一个存活。您将希望将插入ID保留为空或使用随机生成的ID作为插入ID –

回答

1

插入ID用作重复数据删除键。您将以分钟为单位的当前时间用作插入ID。这意味着在同一分钟内的所有插入使用相同的重复数据删除键,因此只有最后一个存活。您将希望将插入ID保留为空或使用随机生成的ID作为插入ID。