Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get result iterator in PinotBrokerPageSource constructor #18602

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,16 @@ public class PinotBrokerPageSource
implements ConnectorPageSource
{
private final PinotQueryInfo query;
private final PinotClient pinotClient;
private final ConnectorSession session;
private final List<PinotColumnHandle> columnHandles;
private final List<Decoder> decoders;
private final BlockBuilder[] columnBuilders;
private final long readTimeNanos;
private final Iterator<BrokerResultRow> resultIterator;

private boolean finished;
private long readTimeNanos;
private long completedBytes;
private final AtomicLong currentRowCount = new AtomicLong();
private final int limitForBrokerQueries;

private Iterator<BrokerResultRow> resultIterator;

public PinotBrokerPageSource(
ConnectorSession session,
PinotQueryInfo query,
Expand All @@ -62,16 +58,16 @@ 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;

this.columnBuilders = columnHandles.stream()
.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<Decoder> createDecoders(List<PinotColumnHandle> columnHandles)
Expand Down Expand Up @@ -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;
Expand Down