diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java index 798fb2af43a8..4074959404b7 100644 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java @@ -40,20 +40,16 @@ public class PinotBrokerPageSource implements ConnectorPageSource { private final PinotQueryInfo query; - private final PinotClient pinotClient; - private final ConnectorSession session; - private final List columnHandles; private final List decoders; private final BlockBuilder[] columnBuilders; + private final long readTimeNanos; + private final Iterator resultIterator; private boolean finished; - private long readTimeNanos; private long completedBytes; private final AtomicLong currentRowCount = new AtomicLong(); private final int limitForBrokerQueries; - private Iterator resultIterator; - public PinotBrokerPageSource( ConnectorSession session, PinotQueryInfo query, @@ -62,9 +58,6 @@ public PinotBrokerPageSource( int limitForBrokerQueries) { this.query = requireNonNull(query, "query is null"); - this.pinotClient = requireNonNull(pinotClient, "pinotClient is null"); - this.session = requireNonNull(session, "session is null"); - this.columnHandles = requireNonNull(columnHandles, "columnHandles is null"); this.decoders = createDecoders(columnHandles); this.limitForBrokerQueries = limitForBrokerQueries; @@ -72,6 +65,9 @@ public PinotBrokerPageSource( .map(PinotColumnHandle::getDataType) .map(type -> type.createBlockBuilder(null, 1)) .toArray(BlockBuilder[]::new); + long start = System.nanoTime(); + resultIterator = pinotClient.createResultIterator(session, query, columnHandles); + readTimeNanos = System.nanoTime() - start; } private static List createDecoders(List columnHandles) @@ -107,12 +103,6 @@ public Page getNextPage() if (finished) { return null; } - if (resultIterator == null) { - long start = System.nanoTime(); - resultIterator = pinotClient.createResultIterator(session, query, columnHandles); - readTimeNanos = System.nanoTime() - start; - } - if (!resultIterator.hasNext()) { finished = true; return null;