Package org.apache.druid.sql.avatica
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 -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.calcite.avatica.Meta.Framecall()Fetch the next batch up to the batch size or EOF.intoffset()Result is only valid between executions, which turns out to be the only time it is called.voidsetBatchSize(int batchSize) In an ideal world, the batch size would be a constructor parameter.
-
Constructor Details
-
ResultFetcher
-
-
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.
-