Class AggregationQueryPager
- java.lang.Object
-
- org.apache.cassandra.service.pager.AggregationQueryPager
-
- All Implemented Interfaces:
QueryPager
public final class AggregationQueryPager extends java.lang.Object implements QueryPager
QueryPager
that takes care of fetching the pages for aggregation queries.For aggregation/group by queries, the user page size is in number of groups. But each group could be composed of very many rows so to avoid running into OOMs, this pager will page internal queries into sub-pages. So each call to
fetchPage(int,org.apache.cassandra.db.ConsistencyLevel,org.apache.cassandra.service.ClientState,org.apache.cassandra.transport.Dispatcher.RequestTime)
may (transparently) yield multiple internal queries (sub-pages).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AggregationQueryPager.AggregationPartitionIterator
PartitionIterator
for queries without Group By but with aggregates.class
AggregationQueryPager.GroupByPartitionIterator
PartitionIterator
that automatically fetch a new sub-page of data if needed when the current iterator is exhausted.
-
Field Summary
-
Fields inherited from interface org.apache.cassandra.service.pager.QueryPager
EMPTY
-
-
Constructor Summary
Constructors Constructor Description AggregationQueryPager(QueryPager subPager, DataLimits limits)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadExecutionController
executionController()
Starts a new read operation.PartitionIterator
fetchPage(int pageSize, ConsistencyLevel consistency, ClientState clientState, Dispatcher.RequestTime requestTime)
Fetches the next page.PartitionIterator
fetchPageInternal(int pageSize, ReadExecutionController executionController)
Fetches the next page internally (in other, this does a local query).boolean
isExhausted()
Whether or not this pager is exhausted, i.e.boolean
isTopK()
int
maxRemaining()
The maximum number of cells/CQL3 row that we may still have to return.PagingState
state()
Get the current state of the pager.QueryPager
withUpdatedLimit(DataLimits newLimits)
Creates a newQueryPager
that use the new limits.
-
-
-
Constructor Detail
-
AggregationQueryPager
public AggregationQueryPager(QueryPager subPager, DataLimits limits)
-
-
Method Detail
-
fetchPage
public PartitionIterator fetchPage(int pageSize, ConsistencyLevel consistency, ClientState clientState, Dispatcher.RequestTime requestTime)
Description copied from interface:QueryPager
Fetches the next page.- Specified by:
fetchPage
in interfaceQueryPager
- Parameters:
pageSize
- the maximum number of elements to return in the next page.consistency
- the consistency level to achieve for the query.clientState
- theClientState
for the query. In practice, this can be null unlessconsistency
is a serial consistency.- Returns:
- the page of result.
-
executionController
public ReadExecutionController executionController()
Description copied from interface:QueryPager
Starts a new read operation.This must be called before
QueryPager.fetchPageInternal(int,org.apache.cassandra.db.ReadExecutionController)
and passed to it to protect the read. The returned object must be closed on all path and it is thus strongly advised to use it in a try-with-ressource construction.- Specified by:
executionController
in interfaceQueryPager
- Returns:
- a newly started order group for this
QueryPager
.
-
fetchPageInternal
public PartitionIterator fetchPageInternal(int pageSize, ReadExecutionController executionController)
Description copied from interface:QueryPager
Fetches the next page internally (in other, this does a local query).- Specified by:
fetchPageInternal
in interfaceQueryPager
- Parameters:
pageSize
- the maximum number of elements to return in the next page.executionController
- theReadExecutionController
protecting the read.- Returns:
- the page of result.
-
isExhausted
public boolean isExhausted()
Description copied from interface:QueryPager
Whether or not this pager is exhausted, i.e. whether or not a call to fetchPage may return more result.- Specified by:
isExhausted
in interfaceQueryPager
- Returns:
- whether the pager is exhausted.
-
maxRemaining
public int maxRemaining()
Description copied from interface:QueryPager
The maximum number of cells/CQL3 row that we may still have to return. In other words, that's the initial user limit minus what we've already returned (note that it's not how many we *will* return, just the upper limit on it).- Specified by:
maxRemaining
in interfaceQueryPager
-
state
public PagingState state()
Description copied from interface:QueryPager
Get the current state of the pager. The state can allow to restart the paging on another host from where we are at this point.- Specified by:
state
in interfaceQueryPager
- Returns:
- the current paging state. Will return null if paging is at the beginning. If the pager is exhausted, the result is undefined.
-
withUpdatedLimit
public QueryPager withUpdatedLimit(DataLimits newLimits)
Description copied from interface:QueryPager
Creates a newQueryPager
that use the new limits.- Specified by:
withUpdatedLimit
in interfaceQueryPager
- Parameters:
newLimits
- the new limits- Returns:
- a new
QueryPager
that use the new limits
-
isTopK
public boolean isTopK()
- Specified by:
isTopK
in interfaceQueryPager
- Returns:
- true given read query is a top-k request
-
-