[
https://issues.apache.org/jira/browse/CASSANDRA-8871?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tyler Hobbs resolved CASSANDRA-8871.
------------------------------------
Resolution: Not a Problem
Reproduced In: 2.1.3, 2.0.12 (was: 2.0.12, 2.1.3)
The reason this happens is that Cassandra doesn't actually know if there are
more rows to be read or not. Basically, it tries to read a page's worth of
data, and if it gets as many rows as it asked for, it assumes there are more to
read, and so a paging state is returned. The only way to avoid this would be
to read one extra row on every page. I don't think it's worth that to avoid
returning a non-null paging state in this case, so I'm going to resolve this as
Not A Problem. Let me know if I've missed something.
> Non-null paging state returned if last page
> -------------------------------------------
>
> Key: CASSANDRA-8871
> URL: https://issues.apache.org/jira/browse/CASSANDRA-8871
> Project: Cassandra
> Issue Type: Bug
> Environment: ruby-driver 2.1.0 | C* 2.0.12 | C* 2.1.3
> Reporter: Kishan Karunaratne
> Assignee: Tyler Hobbs
>
> When retrieving the next page from the result of a simple statement, the
> result will return a non-null paging state even if it's the last page of the
> query. This only happens if it's the last page, and the results of the last
> page exactly matches the paging size.
> Schema:
> {noformat}
> CREATE KEYSPACE simplex WITH replication = {'class': 'SimpleStrategy',
> 'replication_factor': 3};
> USE simplex;
> CREATE TABLE test (k text, v int, PRIMARY KEY (k, v));
> INSERT INTO test (k, v) VALUES ('a', 0);
> INSERT INTO test (k, v) VALUES ('b', 1);
> INSERT INTO test (k, v) VALUES ('c', 2);
> INSERT INTO test (k, v) VALUES ('d', 3);
> INSERT INTO test (k, v) VALUES ('e', 4);
> {noformat}
> Query:
> {noformat}
> result = session.execute("SELECT * FROM test", page_size: 5)
> loop do
> puts "last page? #{result.last_page?}"
> puts "page size: #{result.size}"
> result.each do |row|
> puts row
> end
> puts ""
> break if result.last_page?
> result = result.next_page
> end
> {noformat}
> Result:
> {noformat}
> last page? false
> page size: 5
> {"k"=>"a", "v"=>0}
> {"k"=>"c", "v"=>2}
> {"k"=>"m", "v"=>12}
> {"k"=>"f", "v"=>5}
> {"k"=>"o", "v"=>14}
>
> last page? true
> page size: 0
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)