0

Is there any built-in API which provides a pagination feature in Pivotal GemFire, such as in the QueryService API or using Functions? We are currently using Pivotal GemFire 9.3.0 running in PCC.

TIA.

John Blum
  • 7,381
  • 1
  • 20
  • 30
rajanikanth
  • 123
  • 1
  • 2
  • 8

2 Answers2

2

No yet. It is a planned feature for SD Lovelace/Moore release trains. See SGF-524 - Add support for PagingAndSortingRepositories. NOTE: sorting is already supported; paging is a WIP.

John Blum
  • 7,381
  • 1
  • 20
  • 30
0

There is not. However there is a common pattern for this. Instead of directly querying the matching objects, write your query to return the keys of the matching objects. The client can then implement paging (e.g. page1 is key0-key99, page 2 is key 100-199, etc.). Use the "getAll" method with a list of keys to pull back one page at a time.

BTW, you can query the keys like this: "select key from /person.entries where value.ssn='222-22-2222'"

Randy May
  • 348
  • 1
  • 8
  • This is effectively the pattern I am going to implement in SDG for the `PagingAndSortingRepository` impl, as explained in SGF-524. – John Blum Jul 24 '18 at 18:52
  • Thanks Randy. That's exactly what I was thinking to implement. But the issue is page 1 and page 2 are requested by client through HTTP. So Page 2 doesn't have any context of what are the 100 keys data was sent in the first response. – rajanikanth Jul 25 '18 at 23:38
  • True, you would have to store the list of ids somewhere like the session. If you want to get more advanced you could use Functions and store the list of ids in a "cursor" region. One Function takes a query and a unique id, finds the matching keys and stores the ordered list in a single entry using the unique id as the key. That unique id becomes a cursor id. A second function takes the id and a desired page. Given those things it access the list of ids and return the objects for that page. You have to figure out where to get the unique id. Maybe a client id or a hash of the query. – Randy May Jul 26 '18 at 15:19