Click or drag to resize

PagingPredicate Class

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.
Inheritance Hierarchy
SystemObject
  Hazelcast.CorePagingPredicate

Namespace:  Hazelcast.Core
Assembly:  Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.9.3
Syntax
public class PagingPredicate : IPredicate, 
	IIdentifiedDataSerializable

The PagingPredicate type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyComparer
IComparer<KeyValuePair<object, object>>> implementation used to sort the result on client side.
Public propertyIterationType
Iteration type this paging predicate: One of Key, Value or Entry
Public propertyPage
Current page index
Public propertyPageSize
Page size of each iteration
Top
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetFactoryId
Public methodGetHashCode (Inherited from Object.)
Public methodGetId
Public methodGetNearestAnchorEntry
After each query, an anchor entry is set for that page. SetAnchor``2(Int32, UMP, UMP) For the next query user may set an arbitrary Page. 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 3nd page then the nearest anchor belongs to page 2
Public methodGetType (Inherited from Object.)
Public methodNextPage
sets the page value to next page
Public methodPreviousPage
sets the page value to previous page
Public methodReadData
Public methodReset
resets for reuse
Public methodToString (Inherited from Object.)
Public methodWriteData
Top
Extension Methods
  NameDescription
Public Extension MethodAnd (Defined by PredicateExt.)
Public Extension MethodNot (Defined by PredicateExt.)
Public Extension MethodOr (Defined by PredicateExt.)
Top
Remarks
This class is not thread-safe and stateless. To be able to reuse for another query, one should call Reset
Examples
Predicate lessEqualThanFour = Predicates.IsLessThanOrEqual("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("myMap");
for (int i = 0; i < 10; i++)
{
    map.Put(i, i);
}

//invoking the query
var values = map.Values(predicate);
Console.WriteLine("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);
Console.WriteLine("values = " + values);// will print 'values = [2, 3]'
var anchor = predicate.GetAnchor();
Console.WriteLine("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);
Console.WriteLine("values = " + values) // will print 'values = [0, 1]'
See Also