I want to implement pagination on the UI, so I set fetchSize like this:
boundStatement.setFetchSize(20)
But the setFetchSize() is not honored. My table has 400 rows as of now and all 400 rows are retrieved. When I retrieve the next set of rows using
rs.getExecutionInfo().getPagingState();
then the next 380 rows are retrieved. So the paging state is correctly set and retrieved, but why is the driver retreiving all 400 rows from the table and how can I avoid this or make it retrieve only 400
Portion of code:
....
....
// "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 version - 3.7 and cassandra driver version - 3.1.0
Thanks!