使用建议的方法从Quickstart: Using Client Libraries处的google文档初始化BigQuery客户端需要15秒钟才能完成。这似乎很慢-有更快的方法吗?
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
public class Test {
public static void main(String... args) throws Exception {
long nanotime = System.nanoTime();
BigQueryOptions x = BigQueryOptions.getDefaultInstance();
System.out.println("getDefaultInstance " +
(System.nanoTime()-nanotime));
nanotime = System.nanoTime();
BigQuery bigquery = x.getService();
System.out.println("getService " + (System.nanoTime()-nanotime));
}
}
输出:
getDefaultInstance 15453574055
getService 34049521
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 16.021s
Finished at: Tue Mar 19 14:23:54 GMT 2019
Final Memory: 7M/178M
------------------------------------------------------------------------
答案 0 :(得分:2)
This is strange. I can run the same code on my end and it took less than 200ms
to initialize. I'm running the code in a n1-standard-4
VM and using following versions for java:
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
and 1.62
version for BigQuery client:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.62.0</version>
</dependency>
答案 1 :(得分:1)