title: How do I make an async call to Hive in Java?
body: <p>I would like to execute a Hive query on the server in an asynchronous manner. The Hive query will likely take a long time to complete, so I would prefer not to block on the call. I am currently using Thirft to make a blocking call (blocks on client.execute()), but I have not seen an example of how to make a non-blocking call. Here is the blocking code:</p>
  
  <pre><code>        TSocket transport = new TSocket("hive.example.com", 10000);
          transport.setTimeout(999999999);
          TBinaryProtocol protocol = new TBinaryProtocol(transport);
          Client client = new ThriftHive.Client(protocol);
          transport.open();
          client.execute(hql);  // Omitted HQL
  
          List&lt;String&gt; rows;
          while ((rows = client.fetchN(1000)) != null) {
              for (String row : rows) {
                  // Do stuff with row
              }
          }
  
          transport.close();
  </code></pre>
  
  <p>The code above is missing try/catch blocks to keep it short.</p>
  
  <p>Does anyone have any ideas how to do an async call? Can Hive/Thrift support it? Is there a better way?</p>
  
  <p>Thanks!</p>