本文整理汇总了Java中com.hazelcast.query.PagingPredicate类的典型用法代码示例。如果您正苦于以下问题:Java PagingPredicate类的具体用法?Java PagingPredicate怎么用?Java PagingPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PagingPredicate类属于com.hazelcast.query包,在下文中一共展示了PagingPredicate类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTickets
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@Override
public Collection<Ticket> getTickets() {
final Collection<Ticket> collection = new HashSet<>();
final Lock lock = this.hz.getLock(getClass().getName());
lock.lock();
try {
final PagingPredicate pagingPredicate = new PagingPredicate(this.pageSize);
for (Collection<Ticket> entrySet = this.registry.values(pagingPredicate);
!entrySet.isEmpty();
pagingPredicate.nextPage(), entrySet = this.registry.values(pagingPredicate)) {
for (final Ticket entry : entrySet) {
collection.add(decodeTicket(entry));
}
}
} finally {
lock.unlock();
}
return collection;
}
示例2: handleRequest
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
Deque<String> userIdDeque = exchange.getQueryParameters().get("userId");
String userId = userIdDeque == null? "%" : userIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
if(logger.isDebugEnabled()) logger.debug("userId = " + userId + " page = " + page + " pageSize = " + pageSize);
LikePredicate likePredicate = new LikePredicate("userId", userId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new RefreshTokenComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<RefreshToken> values = tokens.values(pagingPredicate);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例3: handleRequest
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
Deque<String> userIdDeque = exchange.getQueryParameters().get("userId");
String userId = userIdDeque == null? "%" : userIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("userId", userId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new UserComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<User> values = users.values(pagingPredicate);
for (User value : values) {
value.setPassword(null);
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例4: handleRequest
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");
Deque<String> serviceIdDeque = exchange.getQueryParameters().get("serviceId");
String serviceId = serviceIdDeque == null? "%" : serviceIdDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("serviceId", serviceId);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ServiceComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Service> values = services.values(pagingPredicate);
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(values));
}
示例5: handleRequest
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
Deque<String> clientNameDeque = exchange.getQueryParameters().get("clientName");
String clientName = clientNameDeque == null? "%" : clientNameDeque.getFirst() + "%";
int page = Integer.valueOf(exchange.getQueryParameters().get("page").getFirst()) - 1;
Deque<String> pageSizeDeque = exchange.getQueryParameters().get("pageSize");
int pageSize = pageSizeDeque == null? 10 : Integer.valueOf(pageSizeDeque.getFirst());
LikePredicate likePredicate = new LikePredicate("clientName", clientName);
PagingPredicate pagingPredicate = new PagingPredicate(likePredicate, new ClientComparator(), pageSize);
pagingPredicate.setPage(page);
Collection<Client> values = clients.values(pagingPredicate);
List results = new ArrayList();
for (Client value : values) {
Client c = Client.copyClient(value);
c.setClientSecret(null);
results.add(c);
}
exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(results));
}
示例6: addListener
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
public KfkaMessageListener addListener(KfkaMessageListener l, KfkaPredicate kfkaPredicate)
{
// Relative offset
final Integer offset = kfkaPredicate.getRelativeOffset();
if (offset == null && kfkaPredicate.getMessageId() != null)
{
// We have just a message id
sendHistoricData(new PagingPredicate<Long, KfkaMessage>(kfkaPredicate.toHazelcastPredicate(), ORDER_BY_ID_DESCENDING, kfkaCfg.getMaxQuerySize()), l);
}
else if (offset != null && kfkaPredicate.getMessageId() == null)
{
// We have just a relative offset
sendHistoricData(new PagingPredicate<Long, KfkaMessage>(kfkaPredicate.toHazelcastPredicate(), ORDER_BY_ID_DESCENDING, -offset), l);
}
// Add to set of listeners, with the desired predicate
msgListeners.put(l, kfkaPredicate);
return l;
}
示例7: sendHistoricData
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
private void sendHistoricData(PagingPredicate<Long, KfkaMessage> pagingPredicate, KfkaMessageListener l)
{
pagingPredicate.setIterationType(IterationType.VALUE);
final Collection<KfkaMessage> hits = messages.values(pagingPredicate);
// Deliver all messages up until now
FluentIterable.from(hits)
.toSortedList(new Comparator<KfkaMessage>()
{
@Override
public int compare(KfkaMessage a, KfkaMessage b)
{
return a.getId().compareTo(b.getId());
}
})
.forEach(e -> l.onMessage(e));
}
示例8: updateContextExpiration
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void updateContextExpiration(@Nonnull String context, @Nullable Long expiration) throws IOException {
IMap<String, StorageRecord> backingMap = this.hazelcastInstance.getMap(context);
final Lock lock = hazelcastInstance.getLock(context);
lock.lock();
try {
PagingPredicate pagingPredicate = new PagingPredicate(this.pageSize);
for (Set<Map.Entry<String, StorageRecord>> entrySet = backingMap.entrySet(pagingPredicate);
!entrySet.isEmpty();
pagingPredicate.nextPage(), entrySet = backingMap.entrySet(pagingPredicate)) {
for (Map.Entry entry : entrySet) {
this.updateExpiration(context, (String) entry.getKey(), expiration);
}
}
} finally {
lock.unlock();
}
}
开发者ID:UniconLabs,项目名称:shibboleth-hazelcast-storage-service,代码行数:22,代码来源:HazelcastMapBackedStorageService.java
示例9: complete
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@Override
protected KeyValueQuery<Predicate<?, ?>> complete(Predicate<?, ?> criteria, Sort sort) {
KeyValueQuery<Predicate<?, ?>> keyValueQuery;
if (this.limit == 0) {
keyValueQuery = new KeyValueQuery<Predicate<?, ?>>(criteria);
} else {
keyValueQuery = new KeyValueQuery<Predicate<?, ?>>(new PagingPredicate(criteria, this.limit));
}
if (sort != null) {
keyValueQuery.setSort(sort);
}
return keyValueQuery;
}
示例10: resolve
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
/**
* @param A query in Spring form
* @return The same in Hazelcast form
*/
public Predicate<?, ?> resolve(KeyValueQuery<?> query) {
if (query == null || query.getCritieria() == null) {
return null;
}
if (query.getCritieria() instanceof PagingPredicate) {
PagingPredicate pagingPredicate = (PagingPredicate) query.getCritieria();
query.limit(pagingPredicate.getPageSize());
return pagingPredicate.getPredicate();
}
if (query.getCritieria() instanceof Predicate) {
return (Predicate<?, ?>) query.getCritieria();
}
throw new UnsupportedOperationException(query.toString());
}
示例11: pagePredicate
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@TimeStep(prob = 0.2)
public void pagePredicate(ThreadState state) {
double maxSalary = state.randomDouble() * Employee.MAX_SALARY;
Predicate predicate = Predicates.lessThan("salary", maxSalary);
SalaryComparator salaryComparator = new SalaryComparator();
PagingPredicate pagingPredicate = new PagingPredicate(predicate, salaryComparator, pageSize);
Collection<Employee> employees;
List<Employee> employeeList;
do {
employees = map.values(pagingPredicate);
employeeList = fillListWithQueryResultSet(employees);
Employee nextEmployee;
Employee currentEmployee;
for (int i = 0; i < employeeList.size() - 1; i++) {
currentEmployee = employeeList.get(i);
nextEmployee = employeeList.get(i + 1);
// check the order & max salary
assertTrue(format(baseAssertMessage, currentEmployee.getSalary(), predicate),
currentEmployee.getSalary() <= nextEmployee.getSalary() && nextEmployee.getSalary() < maxSalary);
}
pagingPredicate.nextPage();
} while (!employees.isEmpty());
state.operationCounter.pagePredicateCount++;
}
示例12: find
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends HazelcastEntity> Collection<T> find(Predicate predicate, int pageSize, Class<T> tClass) {
final Predicate pagingPredicate = (pageSize > 0)
? new PagingPredicate(predicate, new HazelcastEntityComparator(), pageSize)
: predicate;
return (Collection<T>) mapsHolder.get(tClass).values(pagingPredicate);
}
示例13: createNewPredicate
import com.hazelcast.query.PagingPredicate; //导入依赖的package包/类
private PagingPredicate createNewPredicate() {
return new PagingPredicate(innerPredicate, pageSize);
}