Java 有没有更快的方法初始化BigQuery客户端?
使用推荐的方法从google文档中初始化BigQuery客户端需要15秒才能完成。这似乎很慢-有没有更快的方法Java 有没有更快的方法初始化BigQuery客户端?,java,google-bigquery,vmware-fusion,Java,Google Bigquery,Vmware Fusion,使用推荐的方法从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
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
------------------------------------------------------------------------
这很奇怪。我可以在我的终端上运行相同的代码,初始化不到200毫秒。我在
n1-standard-4
VM中运行代码,并使用以下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)
以及BigQuery客户端的1.62
版本:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.62.0</version>
</dependency>
com.google.cloud
问题与虚拟机上的网络配置有关。将网络设置从“与我的Mac共享”更改为“桥接网络”解决了这个问题(参见下图)。现在初始化需要0.6秒
嗨,克里斯,我使用JS,客户端以毫秒初始化。你能不能完整的代码,时间戳日志和其他信息,以便更好地理解这个问题,它应该需要毫秒。通过这个测试,我可以在不到1秒的时间内创建一个数据集。我已经在原始问题中添加了一个完整的工作测试程序@你在用java吗?非常感谢。知道它可能很快是很有用的。该测试消除了许多可能的问题。