K
- type of the entry keyV
- type of the entry valuepublic interface PagingPredicate<K,V> extends Predicate<K,V>
reset()
.
Predicate lessEqualThanFour = Predicates.lessEqual("this", 4); // We are constructing our paging predicate with a predicate and a page size. In this case query results // are fetched in batches of two. PagingPredicate predicate = Predicates.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 the 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]'
Predicates.pagingPredicate(int)
Modifier and Type | Method and Description |
---|---|
Map.Entry<K,V> |
getAnchor()
Retrieve the anchor object which is the last value object on the previous page.
|
Comparator<Map.Entry<K,V>> |
getComparator()
Returns the comparator used by this predicate (if any).
|
int |
getPage()
Returns the current page value.
|
int |
getPageSize()
Returns the page size.
|
void |
nextPage()
Sets the page value to next page.
|
void |
previousPage()
Sets the page value to previous page.
|
void |
reset()
Resets for reuse.
|
void |
setPage(int page)
Sets the current page value.
|
void reset()
void nextPage()
void previousPage()
int getPage()
void setPage(int page)
page
- the current page value.int getPageSize()
Comparator<Map.Entry<K,V>> getComparator()
null
Map.Entry<K,V> getAnchor()
Note: This method will return `null` on the first page of the query result or if the predicate was not applied for the previous page number.
Copyright © 2024 Hazelcast, Inc.. All rights reserved.