Search in sources :

Example 1 with RuleBasedQueryOptimizer

use of com.hazelcast.query.impl.predicates.RuleBasedQueryOptimizer in project hazelcast by hazelcast.

the class PagingPredicateOptimizationTest method testInnerPredicateOptimization.

@Test
public void testInnerPredicateOptimization() {
    RuleBasedQueryOptimizer optimizer = new RuleBasedQueryOptimizer();
    Indexes indexes = mock(Indexes.class);
    Predicate[] orPredicates = new Predicate[10];
    for (int i = 0; i < orPredicates.length; ++i) {
        orPredicates[i] = Predicates.equal("a", i);
    }
    Predicate innerPredicate = Predicates.or(orPredicates);
    PagingPredicate<Object, Object> pagingPredicate = Predicates.pagingPredicate(innerPredicate, 10);
    Predicate optimized = optimizer.optimize(pagingPredicate, indexes);
    assertInstanceOf(PagingPredicateImpl.class, optimized);
    Predicate innerOptimized = ((PagingPredicateImpl) optimized).getPredicate();
    assertInstanceOf(InPredicate.class, innerOptimized);
}
Also used : RuleBasedQueryOptimizer(com.hazelcast.query.impl.predicates.RuleBasedQueryOptimizer) Indexes(com.hazelcast.query.impl.Indexes) InPredicate(com.hazelcast.query.impl.predicates.InPredicate) PagingPredicate(com.hazelcast.query.PagingPredicate) Predicate(com.hazelcast.query.Predicate) PagingPredicateImpl(com.hazelcast.query.impl.predicates.PagingPredicateImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

PagingPredicate (com.hazelcast.query.PagingPredicate)1 Predicate (com.hazelcast.query.Predicate)1 Indexes (com.hazelcast.query.impl.Indexes)1 InPredicate (com.hazelcast.query.impl.predicates.InPredicate)1 PagingPredicateImpl (com.hazelcast.query.impl.predicates.PagingPredicateImpl)1 RuleBasedQueryOptimizer (com.hazelcast.query.impl.predicates.RuleBasedQueryOptimizer)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1