Package com.google.api.services.bigquery.model

Examples of com.google.api.services.bigquery.model.QueryResponse


@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
  log.info("SERVLET doGet");

    // query = "select count(*) from [publicdata:samples.shakespeare]";
    QueryResponse qr = executeQuickQuery(jobs, projectid, query);
    String msg = qr.toPrettyString();
    log.info("Query: '" + query + "'\nResponse: " + msg);

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");
    PrintWriter writer = response.getWriter();
View Full Code Here


QueryResponse executeQuickQuery(Jobs jobs, String projectid, String query) throws IOException {
  long starttime = System.nanoTime();
 
  QueryRequest queryrequest = new QueryRequest().setQuery(query);
  QueryResponse queryresponse = jobs.query(projectid, queryrequest).execute();

  TableSchema schema = queryresponse.getSchema();
  log.info("Table schema: " + schema.toPrettyString());
  List<TableFieldSchema> fields = schema.getFields();
  for (TableFieldSchema field : fields) {
    String name = field.getName();
    String type = field.getType();
    String mode = field.getMode();
    log.info("Field name: " + name + " type: " + " mode: " + mode);
  }

  BigInteger numberrows = queryresponse.getTotalRows();
  log.info("Total rows: " + numberrows);
  String pagetoken = queryresponse.getPageToken();
  log.info("Page token: " + pagetoken);

  String jobid = queryresponse.getJobReference().getJobId();
  GetQueryResultsResponse results = jobs.getQueryResults(projectid, jobid).execute();
  long endtime = 0;
  if (results.getJobComplete()) {
    endtime = System.nanoTime();
    List<TableRow> rows = results.getRows();
View Full Code Here

TOP

Related Classes of com.google.api.services.bigquery.model.QueryResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.