Python pagination

Hi! I cant find a method which provide functionality for pagination.

I use this syntax for select some bins from DB: scan = aerospike_Client.scan(AEROSPIKE_NAMESPACE, AEROSPIKE_SET) results = scan.results(policy.compile()) - policy is filters expressions

What do i need? I need method for getting partitioned bins (such as limit and offset in postgresql). I declarate it and get only those bins. For example: limit 5, offset 3200 - it means that aerospike return bins 3200, 3201, 3202, 3203, 3204. next request may be with another filters and pagination params.

Pleas, help me! Thx a lot

You can find the documentation on pagination here. The paginate() method is described here. The doc describes how to scan specific partitions and records using the scan policy “partition_filter” as of client 7.0.0 and with server >= 6.0. You can use “max_records” in policy and “digest” in partition_status that are equivalent to limit and offset respectively.

Note, bins in Aerospike terminology are equivalent to fields or columns, not records.

(post deleted by author)

The example code for pagination should be applicable in most cases. Please take a look at the code examples here and here. It will be good to understand if and how they do not meet your specific requirements. You need not set the digest explicitly in most cases; just set the initial partition_status for the next page scan to one returned by get_parititons_status() from the previous one.

The problem is that I need independent pagination. I should be able to specify filters in the first request and get 10 pages of selection. And in the next request with other filters, get page 48. I shouldn’t rely on the previous partition_status in any way.

I need a correct example, because this information is nowhere to be found

You should be able to use a filter with a scan operation, but cannot start a scan at an arbitrary point. You may consider getting the entire range of pages (e.g., 10 pages holding 500 objects) the user may select from, and paginate from the application.

If retrieving an arbitrary range of objects is required, consider storing the paginated objects in a List or Map. You will find code examples in the Collection Data Type (CDT) tutorials. While they are in Java and do not have a specific pagination code example, hope they are helpful.