Class DruidJdbcResultSet.ResultFetcher

java.lang.Object
org.apache.druid.sql.avatica.DruidJdbcResultSet.ResultFetcher
All Implemented Interfaces:
Callable<org.apache.calcite.avatica.Meta.Frame>
Enclosing class:
DruidJdbcResultSet

public static class DruidJdbcResultSet.ResultFetcher extends Object implements Callable<org.apache.calcite.avatica.Meta.Frame>
Asynchronous result fetcher. JDBC operates via REST, which is subject to a timeout if a query takes too long to respond. Fortunately, JDBC uses a batched API, and is perfectly happy to get an empty batch. This class runs in a separate thread to fetch a batch. If the fetch takes too long, the JDBC request thread will time out waiting, will return an empty batch to the client, and will remember the fetch for use in the next fetch request. The result is that the time it takes to produce results for long running queries is decoupled from the HTTP timeout.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResultFetcher(int limit, Yielder<Object[]> yielder)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.calcite.avatica.Meta.Frame
    Fetch the next batch up to the batch size or EOF.
    int
    Result is only valid between executions, which turns out to be the only time it is called.
    void
    setBatchSize(int batchSize)
    In an ideal world, the batch size would be a constructor parameter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResultFetcher

      public ResultFetcher(int limit, Yielder<Object[]> yielder)
  • Method Details

    • setBatchSize

      public void setBatchSize(int batchSize)
      In an ideal world, the batch size would be a constructor parameter. But, JDBC, oddly, allows a different batch size per request. Hence, we set the size using this method before each fetch attempt.
    • offset

      public int offset()
      Result is only valid between executions, which turns out to be the only time it is called.
    • call

      public org.apache.calcite.avatica.Meta.Frame call()
      Fetch the next batch up to the batch size or EOF. Return the resulting frame. Exceptions are handled by the executor framework.
      Specified by:
      call in interface Callable<org.apache.calcite.avatica.Meta.Frame>