Java Code Examples for com.hazelcast.query.Predicates#equal()

The following examples show how to use com.hazelcast.query.Predicates#equal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 6 votes vote down vote up
private Predicate<?, ?> fromEqualityVariant(Type type, boolean ignoreCase, String property,
                                            Iterator<Comparable<?>> iterator) {
    switch (type) {
        case SIMPLE_PROPERTY:
            if (ignoreCase) {
                return Predicates.ilike(property, iterator.next().toString());
            } else {
                return Predicates.equal(property, iterator.next());
            }
        case NEGATING_SIMPLE_PROPERTY:
            if (ignoreCase) {
                return Predicates.not(Predicates.ilike(property, iterator.next().toString()));
            } else {
                return Predicates.notEqual(property, iterator.next());
            }
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example 2
Source File: MultiValueMapTest.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
@TimeStep(prob = -1)
public void query(ThreadState state, Probe probe, @StartNanos long startNanos) {
    int key = state.getRandomKey();
    Predicate predicate = Predicates.equal("payloadField[any]", key);
    Collection<Object> result = null;
    try {
        result = map.values(predicate);
    } finally {
        probe.done(startNanos);
    }

    if (throttlingLogger.requestLogSlot()) {
        throttlingLogger.logInSlot(Level.INFO,
                format("Query 'payloadField[any]= %d' returned %d results.", key, result.size()));
    }

    for (Object resultSillySequence : result) {
        state.assertValidSequence(resultSillySequence);
    }
}
 
Example 3
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromBooleanVariant(Type type, String property) {
    switch (type) {
        case TRUE:
            return Predicates.equal(property, true);
        case FALSE:
            return Predicates.equal(property, false);
        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example 4
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromNullVariant(Type type, String property) {
    switch (type) {
        case IS_NULL:
            return Predicates.equal(property, null);
        case IS_NOT_NULL:
            return Predicates.notEqual(property, null);

        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example 5
Source File: HazelcastQueryCreator.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
private Predicate<?, ?> fromEmptyVariant(Type type, String property) {
    switch (type) {
        case IS_EMPTY:
            return Predicates.equal(property, "");
        case IS_NOT_EMPTY:
            return Predicates.notEqual(property, "");

        default:
            throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
    }
}
 
Example 6
Source File: SerializationStrategyTest.java    From hazelcast-simulator with Apache License 2.0 5 votes vote down vote up
@TimeStep(prob = 1)
public void getByStringIndex(ThreadState state) {
    String string = state.getUniqueString();
    Predicate predicate = Predicates.equal("stringVal", string);
    Set<Map.Entry<String, DomainObject>> entries = map.entrySet(predicate);
    throttlingLogger.log(Level.INFO, "GetByStringIndex: " + entries.size() + " entries");
}
 
Example 7
Source File: MatchDetailHandler.java    From match-trade with Apache License 2.0 4 votes vote down vote up
/**
 * @Title: outMatchDepth 保证了原子操作,无需事务
 * @Description: TODO(out订单处理)
 * @param @param order 入单
 * @return void 返回类型
 * @throws
 */
@Async
public void outMatchDepth(MatchOrder order) {
	List<LevelMatch> list = order.getList();
	try {
		if (null!=list&&list.size()>0) {
			Iterator<LevelMatch> itr = list.iterator();
			while (itr.hasNext()){
				LevelMatch lm = itr.next();
				itr.remove();
				BigDecimal dealNumber = lm.getNumber();
				while (dealNumber.compareTo(BigDecimal.ZERO)>0) {
					//对手盘
					IMap<Long, MatchOrder> order_map = hzInstance.getMap(HazelcastUtil.getOrderBookKey(order.getCoinTeam(), !order.getIsBuy()));
					@SuppressWarnings("rawtypes")
					Predicate pricePredicate = Predicates.equal("price", lm.getPrice());
					Collection<MatchOrder> orders = order_map.values(pricePredicate);
					for (MatchOrder mor : orders) {
						MatchOrder out = order_map.remove(mor.getId());
						if (null!=out) {
							int cpr = dealNumber.compareTo(out.getUnFinishNumber());
							if (cpr>0) {
								dealNumber=dealNumber.subtract(out.getUnFinishNumber());
								this.updateOutOder(out, OrderState.ALL, out.getUnFinishNumber());
							}else if (cpr==0) {
								this.updateOutOder(out, OrderState.ALL, dealNumber);
								dealNumber = BigDecimal.ZERO;
								break;
							}else {
								out = this.updateOutOder(out, OrderState.PART, dealNumber);
								order_map.put(out.getId(), out);
								dealNumber = BigDecimal.ZERO;
								break;
							}
						}
					}
				}
			}
		}
	} catch (Exception e) {
		log.error("===出单数据处理异常,数据原型:"+order.toJsonString()+"   本次异常:"+e);
	}
}