![]() |
Hazelcast C++ Client
Hazelcast C++ Client Library
|
NOTE: paging_predicate can only be used with values(), keySet() and entries() methods!!! More...
#include <paging_predicate.h>
Inheritance diagram for hazelcast::client::query::paging_predicate< K, V >:Public Member Functions | |
| void | reset () |
| resets for reuse | |
| void | next_page () |
| sets the page value to next page | |
| void | previous_page () |
| sets the page value to previous page | |
| iteration_type | get_iteration_type () const |
| void | set_iteration_type (iteration_type type) |
| size_t | get_page () const |
| void | set_page (size_t page_number) |
| size_t | get_page_size () const |
| const query::entry_comparator< K, V > * | get_comparator () const |
| void | set_anchor_data_list (anchor_data_list anchor_data_list) |
NOTE: paging_predicate can only be used with values(), keySet() and entries() methods!!!
This class is a special Predicate which helps to get a page-by-page result of a query. It can be constructed with a page-size, an inner predicate for filtering, and a comparator for sorting. This class is not thread-safe and stateless. To be able to reuse for another query, one should call paging_predicate#reset()
Here is an example usage.
Predicate lessEqualThanFour = Predicates.lessEqual("this", 4);
// We are constructing our paging predicate with a predicate and page size. In this case query results fetched two
by two.
paging_predicate predicate = new paging_predicate(lessEqualThanFour, 2);
// we are initializing our map with integers from 0 to 10 as keys and values.
IMap map = hazelcastInstance.getMap(...);
for (int i = 0; i < 10; i++) {
map.put(i, i);
}
// invoking the query
Collection<Integer> values = map.values(predicate);
System.out.println("values = " + values) // will print 'values = [0, 1]'
predicate.nextPage(); // we are setting up paging predicate to fetch next page in the next call.
values = map.values(predicate);
System.out.println("values = " + values);// will print 'values = [2, 3]'
Entry anchor = predicate.getAnchor();
System.out.println("anchor -> " + anchor); // will print 'anchor -> 1=1', since the anchor is the last entry of
the previous page.
predicate.previousPage(); // we are setting up paging predicate to fetch previous page in the next call
values = map.values(predicate);
System.out.println("values = " + values) // will print 'values = [0, 1]'
Definition at line 109 of file paging_predicate.h.