Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
hazelcast::client::query::paging_predicate< K, V > Class Template Reference

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)

Detailed Description

template<typename K, typename V>
class hazelcast::client::query::paging_predicate< K, V >

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 116 of file paging_predicate.h.

Member Function Documentation

◆ get_comparator()

template<typename K, typename V>
const query::entry_comparator< K, V > * hazelcast::client::query::paging_predicate< K, V >::get_comparator ( ) const
inline

Definition at line 163 of file paging_predicate.h.

164 {
165 return comparator_.get();
166 }

◆ get_iteration_type()

template<typename K, typename V>
iteration_type hazelcast::client::query::paging_predicate< K, V >::get_iteration_type ( ) const
inline

Definition at line 153 of file paging_predicate.h.

153{ return iteration_type_; }

◆ get_page()

template<typename K, typename V>
size_t hazelcast::client::query::paging_predicate< K, V >::get_page ( ) const
inline

Definition at line 157 of file paging_predicate.h.

157{ return page_; }

◆ get_page_size()

template<typename K, typename V>
size_t hazelcast::client::query::paging_predicate< K, V >::get_page_size ( ) const
inline

Definition at line 161 of file paging_predicate.h.

161{ return page_size_; }

◆ next_page()

template<typename K, typename V>
void hazelcast::client::query::paging_predicate< K, V >::next_page ( )
inline

sets the page value to next page

Definition at line 141 of file paging_predicate.h.

141{ ++page_; }

◆ previous_page()

template<typename K, typename V>
void hazelcast::client::query::paging_predicate< K, V >::previous_page ( )
inline

sets the page value to previous page

Definition at line 146 of file paging_predicate.h.

147 {
148 if (page_ != 0) {
149 --page_;
150 }
151 }

◆ reset()

template<typename K, typename V>
void hazelcast::client::query::paging_predicate< K, V >::reset ( )
inline

resets for reuse

Definition at line 130 of file paging_predicate.h.

131 {
132 iteration_type_ = iteration_type::VALUE;
133 anchor_data_list_.page_list.clear();
134 anchor_data_list_.data_list.clear();
135 page_ = 0;
136 }
NOTE: paging_predicate can only be used with values(), keySet() and entries() methods!

◆ set_anchor_data_list()

template<typename K, typename V>
void hazelcast::client::query::paging_predicate< K, V >::set_anchor_data_list ( anchor_data_list anchor_data_list)
inline

Definition at line 168 of file paging_predicate.h.

169 {
170 anchor_data_list_ = std::move(anchor_data_list);
171 }

◆ set_iteration_type()

template<typename K, typename V>
void hazelcast::client::query::paging_predicate< K, V >::set_iteration_type ( iteration_type type)
inline

Definition at line 155 of file paging_predicate.h.

155{ iteration_type_ = type; }

◆ set_page()

template<typename K, typename V>
void hazelcast::client::query::paging_predicate< K, V >::set_page ( size_t page_number)
inline

Definition at line 159 of file paging_predicate.h.

159{ page_ = page_number; }

The documentation for this class was generated from the following file: