我想在UI上实现分页,所以我像这样设置fetchSize:
boundStatement.setFetchSize(20)
但是setFetchSize()不受尊重.我的表目前有400行,检索到所有400行.当我使用时检索下一组行
rs.getExecutionInfo().getPagingState();
然后检索接下来的380行.因此,正确设置和检索分页状态,但为什么驱动程序从表中检索所有400行,如何避免这种情况或仅检索400
部分代码:
....
....
// "SELECT * FROM abc.sometable"
BoundStatement boundStatement = pStmt.bind();
boundStatement.setFetchSize(20);
if (pagingState != null) {
boundStatement.setPagingState(PagingState.fromString(pagingState));
}
ResultSet rs = session.execute(boundStatement);
PagingState nextPage = rs.getExecutionInfo().getPagingState();
int remaining = rs.getAvailableWithoutFetching();
List> list = new ArrayList<>();
for (Row row : rs) {
list.add(getValidObjectFromRow(row));
}
....
Cassandra版本 – 3.7和cassandra驱动程序版本 – 3.1.0
谢谢!