3
votes

Datastax's java driver for cassandra provides Accessor. Refer here

With reference to their example as below, do they do pagination and fetch records in batches or is there a risk of the queries timing out ?

@Accessor
public interface UserAccessor {
    @Query("SELECT * FROM user")
    Result<User> getAll();
}

When I say pagination, do they internally do something similar to below

Statement stmt = new SimpleStatement("SELECT * FROM user");
stmt.setFetchSize(24);
ResultSet rs = session.execute(stmt);
2

2 Answers

6
votes

Yes there is a fetch size used behind the scenes. The driver will auto page for you as needed.

You will probably want to set a fetch size via @QueryParameters. The default at this time is 5k, see DEFAULT_FETCH_SIZE.

2
votes

Here is an example of how I am using the fetchSize in the @QueryParameters annotation within an Accessor:

@Accessor
public interface UserAccessor {       

  @Query("SELECT * FROM users")
  @QueryParameters(fetchSize = 1000)
  Result<User> getAllUsers();
}