Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
Public Member Functions | List of all members
hazelcast::client::query::PagingPredicate< K, V > Class Template Reference

NOTE: PagingPredicate can only be used with values(), keySet() and entries() methods!!! More...

#include <PagingPredicate.h>

+ Inheritance diagram for hazelcast::client::query::PagingPredicate< K, V >:

Public Member Functions

 PagingPredicate (size_t predicatePageSize)
 Construct with a pageSize results will not be filtered results will be natural ordered throws IllegalArgumentException IllegalArgumentException if pageSize is not greater than 0. More...
 
 PagingPredicate (std::auto_ptr< Predicate > predicate, size_t predicatePageSize)
 Construct with an inner predicate and pageSize results will be filtered via inner predicate results will be natural ordered throws IllegalArgumentException IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException IllegalArgumentException if inner predicate is also PagingPredicate. More...
 
 PagingPredicate (std::auto_ptr< query::EntryComparator< K, V > > comparatorObj, size_t predicatePageSize)
 Construct with a comparator and pageSize results will not be filtered results will be ordered via comparator throws IllegalArgumentException IllegalArgumentException if pageSize is not greater than 0. More...
 
 PagingPredicate (std::auto_ptr< Predicate > predicate, std::auto_ptr< query::EntryComparator< K, V > > comparatorObj, size_t predicatePageSize)
 Construct with an inner predicate, comparator and pageSize results will be filtered via inner predicate results will be ordered via comparator throws IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException if inner predicate is also PagingPredicate. More...
 
void reset ()
 resets for reuse
 
void nextPage ()
 sets the page value to next page
 
void previousPage ()
 sets the page value to previous page
 
IterationType getIterationType () const
 
void setIterationType (IterationType type)
 
size_t getPage () const
 
void setPage (size_t pageNumber)
 
size_t getPageSize () const
 
const PredicategetPredicate () const
 
const query::EntryComparator
< K, V > * 
getComparator () const
 
const std::pair< K *, V * > * getAnchor () const
 Retrieve the anchor object which is the last value object on the previous page. More...
 
const std::pair< size_t,
std::pair< K *, V * > > * 
getNearestAnchorEntry ()
 After each query, an anchor entry is set for that page. More...
 
int getFactoryId () const
 
int getClassId () const
 
void writeData (serialization::ObjectDataOutput &out) const
 Defines how this class will be written. More...
 
void readData (serialization::ObjectDataInput &in)
 Defines how this class will be read. More...
 
void setAnchor (size_t page, const std::pair< K *, V * > &anchorEntry)
 
- Public Member Functions inherited from hazelcast::client::serialization::IdentifiedDataSerializable
virtual ~IdentifiedDataSerializable ()
 Destructor.
 

Detailed Description

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

NOTE: PagingPredicate 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 PagingPredicate#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.
PagingPredicate predicate = new PagingPredicate(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]'

Constructor & Destructor Documentation

template<typename K, typename V>
hazelcast::client::query::PagingPredicate< K, V >::PagingPredicate ( size_t  predicatePageSize)
inline

Construct with a pageSize results will not be filtered results will be natural ordered throws IllegalArgumentException IllegalArgumentException if pageSize is not greater than 0.

Parameters
predicatePageSizesize of the page
template<typename K, typename V>
hazelcast::client::query::PagingPredicate< K, V >::PagingPredicate ( std::auto_ptr< Predicate predicate,
size_t  predicatePageSize 
)
inline

Construct with an inner predicate and pageSize results will be filtered via inner predicate results will be natural ordered throws IllegalArgumentException IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException IllegalArgumentException if inner predicate is also PagingPredicate.

Parameters
predicatethe inner predicate through which results will be filtered
predicatePageSizethe page size
template<typename K, typename V>
hazelcast::client::query::PagingPredicate< K, V >::PagingPredicate ( std::auto_ptr< query::EntryComparator< K, V > >  comparatorObj,
size_t  predicatePageSize 
)
inline

Construct with a comparator and pageSize results will not be filtered results will be ordered via comparator throws IllegalArgumentException IllegalArgumentException if pageSize is not greater than 0.

Parameters
comparatorObjthe comparator through which results will be ordered
predicatePageSizethe page size
template<typename K, typename V>
hazelcast::client::query::PagingPredicate< K, V >::PagingPredicate ( std::auto_ptr< Predicate predicate,
std::auto_ptr< query::EntryComparator< K, V > >  comparatorObj,
size_t  predicatePageSize 
)
inline

Construct with an inner predicate, comparator and pageSize results will be filtered via inner predicate results will be ordered via comparator throws IllegalArgumentException if pageSize is not greater than 0 throws IllegalArgumentException if inner predicate is also PagingPredicate.

Parameters
predicatethe inner predicate through which results will be filtered
comparatorObjthe comparator through which results will be ordered
predicatePageSizethe page size

Member Function Documentation

template<typename K, typename V>
const std::pair<K *, V *>* hazelcast::client::query::PagingPredicate< K, V >::getAnchor ( ) const
inline

Retrieve the anchor object which is the last value object on the previous page.

Note: This method will return NULL on the first page of the query result.

Returns
std::pair<K *, V *> the anchor object which is the last value object on the previous page
template<typename K, typename V>
int hazelcast::client::query::PagingPredicate< K, V >::getClassId ( ) const
inlinevirtual
template<typename K, typename V>
int hazelcast::client::query::PagingPredicate< K, V >::getFactoryId ( ) const
inlinevirtual
template<typename K, typename V>
const std::pair<size_t, std::pair<K *, V *> >* hazelcast::client::query::PagingPredicate< K, V >::getNearestAnchorEntry ( )
inline

After each query, an anchor entry is set for that page.

see setAnchor(int, Map.Entry)} For the next query user may set an arbitrary page. see setPage(int) for example: user queried first 5 pages which means first 5 anchor is available if the next query is for the 10th page then the nearest anchor belongs to page 5 but if the next query is for the 3rd page then the nearest anchor belongs to page 2

Returns
nearest anchored entry for current page
template<typename K, typename V>
void hazelcast::client::query::PagingPredicate< K, V >::readData ( serialization::ObjectDataInput in)
inlinevirtual

Defines how this class will be read.

Parameters
readerObjectDataInput

Implements hazelcast::client::serialization::IdentifiedDataSerializable.

template<typename K, typename V>
void hazelcast::client::query::PagingPredicate< K, V >::writeData ( serialization::ObjectDataOutput out) const
inlinevirtual

Defines how this class will be written.

Parameters
writerObjectDataOutput

Implements hazelcast::client::serialization::IdentifiedDataSerializable.


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