2016-11-15 10 views
0

私はappengineのbigqueryにデータをアップロードしようとしています。私は google appengineのbigqueryにデータをストリームする

import com.google.appengine.tools.cloudstorage.*; 

library for appengine特別なを持っているストレージへのアップロードのために

私の質問は:有力候補でBigQueryのためにアップロードするためのライブラリがありますか私は、通常のAPIライブラリを使用する必要がありますか?

@Override 
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { 

     String projectId = "myprojectId"; 
     String datasetId = "mydatasetId"; 
     String tableId = "person"; 
     System.out.println("Enter JSON to stream to BigQuery: \n" + "Press End-of-stream (CTRL-D) to stop"); 

     String string = "[\n {\"Name\": \"test\", \"Age\": 0, \"Weight\": 100.0, \"IsMagic\": false},\n {\"Name\": \"test\", \"Age\": 1, \"Weight\": 100.0, \"IsMagic\": false},\n {\"Name\": \"test\", \"Age\": 2, \"Weight\": 100.0, \"IsMagic\": false},\n {\"Name\": \"test\", \"Age\": 3, \"Weight\": 100.0, \"IsMagic\": false},\n {\"Name\": \"test\", \"Age\": 0, \"Weight\": 100.0, \"IsMagic\": false}\n]"; 
     JsonReader jsonReader = new JsonReader(new StringReader(string)); 

     Iterator<TableDataInsertAllResponse> responses = StreamingSample.run(projectId, datasetId, tableId, jsonReader); 

     while (responses.hasNext()) { 
      log.info(responses.next()); 
     } 

     jsonReader.close(); 


    } 

はこれが正しい方法です:このstreaming sampleから定期的なAPIを使用して - ここ

は私がうまく機能している試みた何ですか?

答えて

1

App EngineのBigQueryライブラリはありません。あなたの例は正しいですが、これはストリーミングデータをアップロードするための推奨方法です。

関連する問題