简体   繁体   English

BigQuery Java API线程安全吗?

[英]Is BigQuery java api thread safe?

I would like to use BigQuery java api 'com.google.cloud:google-cloud-bigquery' in our project. 我想在我们的项目中使用BigQuery Java API'com.google.cloud:google-cloud-bigquery'。 I am creating service instance like this 我正在创建这样的服务实例

BigQuery bq =
        BigQueryOptions.newBuilder()
            .setCredentials(credentials)
            .build()
            .getService();

Should I store this com.google.cloud.bigquery.BigQuery instance somewhere in the app and reuse it for every call? 我是否应该将此com.google.cloud.bigquery.BigQuery实例存储在应用程序中的某个位置,并在每次调用时重复使用? Is it thread safe? 它是线程安全的吗? What is the recommended way? 推荐的方法是什么?

Thanks! 谢谢!

I suggest having this as a global variable and reuse it as you may hit a rate limit due to multiple authentication requests. 我建议将其作为全局变量并重用它,因为由于多个身份验证请求,您可能会达到速率限制。 Moreover, if you plan use Threads, I suggest checking the BigQuery API quotas to consider them in your development. 此外,如果您打算使用Threads,建议您检查BigQuery API配额以在开发中考虑它们。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM