/** * Fetchs the next sub-page. * * @param subPageSize the sub-page size in number of groups * @return the next sub-page */ private final PartitionIterator fetchSubPage(int subPageSize) { return consistency != null ? subPager.fetchPage(subPageSize, consistency, clientState, queryStartNanoTime) : subPager.fetchPageInternal(subPageSize, executionController); }
@Override public boolean isExhausted() { return subPager.isExhausted(); }
@Override public int maxRemaining() { return subPager.maxRemaining(); }
protected Row computeNext() { int nowInSec = FBUtilities.nowInSeconds(); while (currentPage == null || !currentPage.hasNext()) { if (pager.isExhausted()) return endOfData(); try (ReadExecutionController executionController = pager.executionController(); PartitionIterator iter = pager.fetchPageInternal(pageSize, executionController)) { currentPage = select.process(iter, nowInSec).rows.iterator(); } } return new Row(metadata, currentPage.next()); } };
+ "ORDER BY or the IN and sort client side, or disable paging for this query"); List<Row> page = pager.fetchPage(pageSize); ResultMessage.Rows msg = processResults(page, options, limit, now); if (!pager.isExhausted()) msg.result.metadata.setHasMorePages(pager.state());
private ResultMessage.Rows pageCountQuery(QueryPager pager, QueryOptions options, int pageSize, long now, int limit) throws RequestValidationException, RequestExecutionException { int count = 0; while (!pager.isExhausted()) { int maxLimit = pager.maxRemaining(); logger.debug("New maxLimit for paged count query is {}", maxLimit); ResultSet rset = process(pager.fetchPage(pageSize), options, maxLimit, now); count += rset.rows.size(); } // We sometimes query one more result than the user limit asks to handle exclusive bounds with compact tables (see updateLimitForQuery). // So do make sure the count is not greater than what the user asked for. ResultSet result = ResultSet.makeCountResult(keyspace(), columnFamily(), Math.min(count, limit), parameters.countAlias); return new ResultMessage.Rows(result); }
/** * Loads the next <code>RowIterator</code> to be returned. */ private void fetchNextRowIterator() { if (partitionIterator == null) { initialMaxRemaining = subPager.maxRemaining(); partitionIterator = fetchSubPage(pageSize); } while (!partitionIterator.hasNext()) { partitionIterator.close(); int counted = initialMaxRemaining - subPager.maxRemaining(); if (isDone(pageSize, counted) || subPager.isExhausted()) { endOfData = true; closed = true; return; } subPager = updatePagerLimit(subPager, limits, lastPartitionKey, lastClustering); partitionIterator = fetchSubPage(computeSubPageSize(pageSize, counted)); } next = partitionIterator.next(); }
protected Row computeNext() { try { while (currentPage == null || !currentPage.hasNext()) { if (pager.isExhausted()) return endOfData(); currentPage = select.process(pager.fetchPage(pageSize)).rows.iterator(); } return new Row(metadata, currentPage.next()); } catch (RequestValidationException | RequestExecutionException e) { throw new RuntimeException(e); } } };
@Override public PagingState state() { return subPager.state(); }
public PartitionIterator fetchPage(int pageSize, long queryStartNanoTime) { return pager.fetchPage(pageSize, consistency, clientState, queryStartNanoTime); } }
public PartitionIterator fetchPage(int pageSize, long queryStartNanoTime) { return pager.fetchPageInternal(pageSize, executionController); } }
@Override public ReadExecutionController executionController() { return subPager.executionController(); }
/** * Updates the pager with the new limits if needed. * * @param pager the pager previoulsy used * @param limits the DataLimits * @param lastPartitionKey the partition key of the last row returned * @param lastClustering the clustering of the last row returned * @return the pager to use to query the next page of data */ protected QueryPager updatePagerLimit(QueryPager pager, DataLimits limits, ByteBuffer lastPartitionKey, Clustering lastClustering) { GroupingState state = new GroupingState(lastPartitionKey, lastClustering); DataLimits newLimits = limits.forGroupByInternalPaging(state); return pager.withUpdatedLimit(newLimits); }
protected Row computeNext() { int nowInSec = FBUtilities.nowInSeconds(); while (currentPage == null || !currentPage.hasNext()) { if (pager.isExhausted()) return endOfData(); try (ReadExecutionController executionController = pager.executionController(); PartitionIterator iter = pager.fetchPageInternal(pageSize, executionController)) { currentPage = select.process(iter, nowInSec).rows.iterator(); } } return new Row(metadata, currentPage.next()); } };
+ "ORDER BY or the IN and sort client side, or disable paging for this query"); List<Row> page = pager.fetchPage(pageSize); ResultMessage.Rows msg = processResults(page, options, limit, now); if (!pager.isExhausted()) msg.result.metadata.setHasMorePages(pager.state());
/** * Loads the next <code>RowIterator</code> to be returned. */ private void fetchNextRowIterator() { if (partitionIterator == null) { initialMaxRemaining = subPager.maxRemaining(); partitionIterator = fetchSubPage(pageSize); } while (!partitionIterator.hasNext()) { partitionIterator.close(); int counted = initialMaxRemaining - subPager.maxRemaining(); if (isDone(pageSize, counted) || subPager.isExhausted()) { endOfData = true; closed = true; return; } subPager = updatePagerLimit(subPager, limits, lastPartitionKey, lastClustering); partitionIterator = fetchSubPage(computeSubPageSize(pageSize, counted)); } next = partitionIterator.next(); }
@Override public PagingState state() { return subPager.state(); }
public PartitionIterator fetchPage(int pageSize, long queryStartNanoTime) { return pager.fetchPage(pageSize, consistency, clientState, queryStartNanoTime); } }
public PartitionIterator fetchPage(int pageSize, long queryStartNanoTime) { return pager.fetchPageInternal(pageSize, executionController); } }
@Override public ReadExecutionController executionController() { return subPager.executionController(); }