Search in sources :

Example 1 with FunctionalPredicateExpression

use of com.hazelcast.sql.impl.expression.FunctionalPredicateExpression in project hazelcast by hazelcast.

the class MapIndexScanPTest method test_whenBothFiltersAndSpecificProjectionExists_sorted.

@Test
public void test_whenBothFiltersAndSpecificProjectionExists_sorted() {
    List<JetSqlRow> expected = new ArrayList<>();
    for (int i = count; i > 0; i--) {
        map.put(i, new Person("value-" + i, i));
        if (i > count / 2) {
            if (i % 2 == 1) {
                expected.add(jetRow((count - i + 1), "value-" + (count - i + 1), (count - i + 1)));
            }
        }
    }
    IndexConfig indexConfig = new IndexConfig(IndexType.SORTED, "age").setName(randomName());
    map.addIndex(indexConfig);
    Expression<Boolean> remainingFilter = new FunctionalPredicateExpression(row -> {
        int value = row.get(0);
        return value % 2 == 0;
    });
    IndexFilter filter = new IndexRangeFilter(intValue(0), true, intValue(count / 2), true);
    MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, remainingFilter, 0, false);
    TestSupport.verifyProcessor(adaptSupplier(MapIndexScanP.readMapIndexSupplier(metadata))).hazelcastInstance(instance()).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).outputChecker(LENIENT_SAME_ITEMS_IN_ORDER).disableSnapshots().disableProgressAssertion().expectOutput(expected);
}
Also used : ArrayList(java.util.ArrayList) JobConfig(com.hazelcast.jet.config.JobConfig) IndexRangeFilter(com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter) IndexConfig(com.hazelcast.config.IndexConfig) FunctionalPredicateExpression(com.hazelcast.sql.impl.expression.FunctionalPredicateExpression) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexFilter(com.hazelcast.sql.impl.exec.scan.index.IndexFilter) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

IndexConfig (com.hazelcast.config.IndexConfig)1 JobConfig (com.hazelcast.jet.config.JobConfig)1 MapIndexScanMetadata (com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata)1 IndexFilter (com.hazelcast.sql.impl.exec.scan.index.IndexFilter)1 IndexRangeFilter (com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter)1 FunctionalPredicateExpression (com.hazelcast.sql.impl.expression.FunctionalPredicateExpression)1 JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1