use of com.datastax.driver.core.exceptions.PagingStateException in project incubator-hugegraph by apache.
the class CassandraTable method setPageState.
protected void setPageState(Query query, List<Select> selects) {
if (query.noLimit() && !query.paging()) {
return;
}
for (Select select : selects) {
int total = (int) query.total();
if (!query.noLimit()) {
E.checkArgument(total == query.total(), "Invalid query limit %s", query.limit());
} else {
assert total == -1 : total;
}
String page = query.page();
if (page == null) {
// Set limit
assert total > 0 : total;
select.limit(total);
} else {
/*
* NOTE: the `total` may be -1 when query.noLimit(),
* setFetchSize(-1) means the default fetch size will be used.
*/
assert total > 0 || total == -1 : total;
select.setFetchSize(total);
// It's the first time if page is empty, skip setPagingState
if (!page.isEmpty()) {
byte[] position = PageState.fromString(page).position();
try {
select.setPagingState(PagingState.fromBytes(position));
} catch (PagingStateException e) {
throw new BackendException(e);
}
}
}
}
}
Aggregations