ImmutableList.Builder<RowIterable> pages = ImmutableList.builder();
// wait up to max wait for data to arrive; then try to return at least DESIRED_RESULT_BYTES
int bytes = 0;
while (bytes < DESIRED_RESULT_BYTES) {
Page page = exchangeClient.getNextPage(maxWait);
if (page == null) {
break;
}
bytes += page.getSizeInBytes();
pages.add(new RowIterable(session.toConnectorSession(), types, page));
// only wait on first call
maxWait = new Duration(0, TimeUnit.MILLISECONDS);
}