presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchPageSource.java/ElasticsearchPageSource/getNextPage
class ElasticsearchPageSource:    @Override
    public Page getNextPage()
    {
        if (columnBuilders.length == 0) {
            // TODO: emit "count" query against Elasticsearch
            int count = 0;
            while (iterator.hasNext()) {
                iterator.next();
                count++;
            }

            finished = true;
            return new Page(count);
        }

        long size = 0;
        while (size < PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES && iterator.hasNext()) {
            SearchHit hit = iterator.next();
            Map<String, Object> document = hit.getSourceAsMap();

            for (int i = 0; i < decoders.size(); i++) {
                String field = columns.get(i).getName();
                decoders.get(i).decode(hit, () -> getField(document, field), columnBuilders[i]);
            }

            if (hit.getSourceRef() != null) {
                totalBytes += hit.getSourceRef().length();
            }

            size = Arrays.stream(columnBuilders)
                    .mapToLong(BlockBuilder::getSizeInBytes)
                    .sum();
        }

        Block[] blocks = new Block[columnBuilders.length];
        for (int i = 0; i < columnBuilders.length; i++) {
            blocks[i] = columnBuilders[i].build();
            columnBuilders[i] = columnBuilders[i].newBlockBuilderLike(null);
        }

        return new Page(blocks);
    }