Search code examples
javagoogle-bigqueryvmware-fusion

Is there a quicker way to initialise a BigQuery client?


Using the recommended way to initialise a BigQuery client from the google documentation at Quickstart: Using Client Libraries takes 15 seconds to complete. This seems very slow - is there a quicker way?

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));
  }
}

Output:

getDefaultInstance 15453574055
getService 34049521
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 16.021s
Finished at: Tue Mar 19 14:23:54 GMT 2019
Final Memory: 7M/178M
------------------------------------------------------------------------

Solution

  • The problem is somehow related to the network configuration on the virtual machine. Changing the network settings from "Share with my Mac" to "Bridged Networking" solved the issue (see image below). It now takes 0.6 secs to initialise.

    VMWare Network Adapter Settings