I have a cassandra table with 1000 rows. I am using the datastax java driver 2.1.8 with Cassandra 2.1.3
I have set the fetchSize to 10 for a prepared select statement. The code in Scala :
val stmt = preparedStatement.bind()
stmt.setFetchSize(10)
if(nextPage != null )
stmt.setPagingState(nextPage)
val rs = session.execute(stmt)
println( rs.all().count )
val nextPage = rs.getExecutionInfo().getPagingState()
I run this in a loop passing the nextPage value each time, starting with a null value.
But the result returned ignores the fetchSize although the PageState object is created according to the fetchSize. Result counts for each run of the loop are ... 1000 990 980 ... so on.
what I want is the driver to return 10 results each time. What am I missing here ?
Calling all()
will automatically consume all remaining pages. See javadoc on fetchMoreResults for details on how to manually fetch batches of the result.