首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bigquery InsertAll没有按预期工作

Bigquery InsertAll没有按预期工作
EN

Stack Overflow用户
提问于 2017-03-31 19:05:41
回答 1查看 265关注 0票数 0

我使用下面的代码从文件名中插入日志。日志文件包含1000 s行。新的行被添加了几秒钟。但是,当我运行这段代码时,生成的表只有15-20行。

代码语言:javascript
复制
      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);
      }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-06 14:38:03

insert id用作去重复键。您使用当前时间(以分钟为单位)作为插入id。这意味着在同一分钟内的所有插入都使用相同的去重复​键,因此只有最后一个保留下来。您将希望将insert id保留为空,或者使用随机生成的id作为insert ID。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43147944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档