com.hazelcast.query.impl.predicates.SqlPredicate Java Examples

The following examples show how to use com.hazelcast.query.impl.predicates.SqlPredicate. 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: MapPredicateTest.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
@TimeStep(prob = 0.2)
public void sqlString(ThreadState state) {
    long startMs = System.currentTimeMillis();
    boolean active = state.randomBoolean();
    int age = state.randomInt(Employee.MAX_AGE);

    SqlPredicate predicate = new SqlPredicate("active=" + active + " AND age >" + age);
    Collection<Employee> employees = map.values(predicate);

    for (Employee emp : employees) {
        String assertMessage = format(baseAssertMessage, emp, predicate);
        assertTrue(assertMessage, emp.isActive() == active);
        assertTrue(assertMessage, emp.getAge() > age);
    }
    state.operationCounter.sqlStringCount++;
    updateStats(state, startMs);
}
 
Example #2
Source File: HazelcastMapProducerIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void testQuery() throws Exception {
    CamelContext camelctx = createCamelContext();
    camelctx.start();
    try {
        String sql = "bar > 1000";
        Mockito.when(map.values(Mockito.any(SqlPredicate.class))).thenReturn(Arrays.<Object>asList(new Dummy("beta", 2000), new Dummy("gamma", 3000)));

        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeader("direct:queue", null, HazelcastConstants.QUERY, sql);
        Mockito.verify(map).values(Mockito.any(SqlPredicate.class));

        ConsumerTemplate consumer = camelctx.createConsumerTemplate();
        Collection<?> b1 = consumer.receiveBody("seda:out", 5000, Collection.class);

        Assert.assertNotNull(b1);
        Assert.assertEquals(2, b1.size());
    } finally {
        camelctx.close();
    }
}
 
Example #3
Source File: StringBasedHazelcastRepositoryQuery.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(Object[] parameters) {
    String queryStringTemplate = queryMethod.getAnnotatedQuery();
    String queryString = String.format(queryStringTemplate, formatParameters(parameters));
    SqlPredicate sqlPredicate = new SqlPredicate(queryString);
    return getMap(keySpace).values(sqlPredicate);
}
 
Example #4
Source File: MapComplexPredicateTest.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@BeforeRun
public void beforeRun(ThreadState state) {
    state.predicate = new SqlPredicate(query.getSql());
}
 
Example #5
Source File: MapGetVsQueryTest.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
@TimeStep(prob = 0)
public void sqlString(ThreadState state) {
    int id = state.randomInt(itemCount);
    SqlPredicate predicate = new SqlPredicate("id=" + id);
    map.values(predicate);
}
 
Example #6
Source File: PagingPredicateTest.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
@Setup
public void setUp() {
    map = targetInstance.getMap(name);
    innerPredicate = new SqlPredicate(innerPredicateQuery);
}