Manual Pagination in Cassandra

≡放荡痞女 提交于 2019-12-24 18:00:24

问题


I use the manual pagination feature in Cassandra.

client.eachRow(query, params, options, function (n, row) { 
     // Invoked per each row in all the pages
     console.log("row",row);
  }, function (err, result) {
       if(typeof result !== undefined) {
          pageState = result.pageState;
          console.log("pagestate output : ", pageState);
          if(pageState != null) {
              //
          }
       }
  }
  );

Say we have 4 row / entries in a table 'test'.

When I try to query with fetchsize as '2' It returns two entres with result.pageState then I used the same pageState to query the next page and it fetched successfully.

But the problem is

Since the total entry is 4 and the fetch size is 2, In the get next page, I expect the 3rd and 4th entry with the pageState to be null (Since there is no more entries available) but, It is returning 3rd and 4th entry with another page state.

1) In this Case : Is that the page state received is next value's page state (or) last received value's page state? AFAIK It is the last received value's (4th entries) page state, So to identify that we reached to the last entry, I always make one more call (result.nextpage) and If it is undefined then I consider that there is no more entries available, I feel it is an over head to make one more call for every pagination.

2) How to identify that we reached to the end without making the result.nextpage check.

来源:https://stackoverflow.com/questions/49135405/manual-pagination-in-cassandra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!