Search code examples
javacassandrapaginationcassandra-3.0

Cassandra: How long does a page exist?


I paginate through a large collection of data (circa 500 000 000 rows) using PagingState, and do some business intelligence during this process. To be able to resume the process I created this table...

/**
 * This table stores temporary paging state
 */
 CREATE TABLE IF NOT EXISTS lp_operations.paging_state (
     id text,          // ID of process
     pos bigint,       // current position
     page text,        // paging state
     info text,        // info json
     finished tinyint, // finished
     PRIMARY KEY (id)
 ) WITH default_time_to_live = 28800; // 8 hours

..in which i store current page (string representation of PagingState) and JSON meta data associated with calculation.

Questions

  • Can 'page' index expire in Cassandra?
  • How long does it exist (by default)?

Solution

  • No, Cassandra Driver's Paging State will not Expire.

    Because Every time you query with paging state, cassandra actually execute your query every time. It don't store your result. Paging State just tell cassandra from which index the driver want the data .

    Due to internal implementation details, PagingState instances are not portable across native protocol versions. This could become a problem in the following scenario:

    • you’re using the driver 2.0.x and Cassandra 2.0.x, and therefore native protocol v2;
    • a user bookmarks a link to your web service that contains a serialized paging state;
    • you upgrade your server stack to use the driver 2.1.x and Cassandra 2.1.x, so you’re now using protocol v3;

    • the user tries to reload their bookmark, but the paging state was serialized with protocol v2, so trying to reuse it will fail.

    Source : http://docs.datastax.com/en/developer/java-driver/3.2/manual/paging/