Search in sources :

Example 26 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class MapIndexScanPTest method test_whenFilterAndSpecificProjectionExists_sorted.

@Test
public void test_whenFilterAndSpecificProjectionExists_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) {
            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);
    IndexFilter filter = new IndexRangeFilter(intValue(0), true, intValue(count / 2), true);
    MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, 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 : IndexRangeFilter(com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter) IndexConfig(com.hazelcast.config.IndexConfig) ArrayList(java.util.ArrayList) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexFilter(com.hazelcast.sql.impl.exec.scan.index.IndexFilter) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class MapIndexScanPTest method test_fullScanAsc_sorted.

@Test
public void test_fullScanAsc_sorted() {
    List<JetSqlRow> expected = new ArrayList<>();
    for (int i = count; i > 0; i--) {
        map.put(i, new Person("value-" + i, i));
        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);
    IndexFilter filter = new IndexRangeFilter(null, true, null, true);
    MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, 2, 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 : IndexRangeFilter(com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter) IndexConfig(com.hazelcast.config.IndexConfig) ArrayList(java.util.ArrayList) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexFilter(com.hazelcast.sql.impl.exec.scan.index.IndexFilter) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class MapIndexScanPTest method test_fullScanDesc_sorted.

@Test
public void test_fullScanDesc_sorted() {
    List<JetSqlRow> expected = new ArrayList<>();
    for (int i = 0; i <= count; i++) {
        map.put(i, new Person("value-" + i, i));
        expected.add(jetRow((count - i), "value-" + (count - i), (count - i)));
    }
    IndexConfig indexConfig = new IndexConfig(IndexType.SORTED, "age").setName(randomName());
    map.addIndex(indexConfig);
    IndexFilter filter = new IndexRangeFilter(null, true, null, true);
    MapIndexScanMetadata metadata = metadata(indexConfig.getName(), filter, 2, true);
    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 : IndexRangeFilter(com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter) IndexConfig(com.hazelcast.config.IndexConfig) ArrayList(java.util.ArrayList) MapIndexScanMetadata(com.hazelcast.sql.impl.exec.scan.MapIndexScanMetadata) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) IndexFilter(com.hazelcast.sql.impl.exec.scan.index.IndexFilter) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class QueryCacheYamlConfigBuilderHelper method queryCacheIndexesHandle.

@Override
protected void queryCacheIndexesHandle(Node childNode, QueryCacheConfig queryCacheConfig) {
    for (Node indexNode : childElements(childNode)) {
        IndexConfig indexConfig = IndexUtils.getIndexConfigFromYaml(indexNode, domLevel3, strict);
        queryCacheConfig.addIndexConfig(indexConfig);
    }
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) Node(org.w3c.dom.Node)

Example 30 with IndexConfig

use of com.hazelcast.config.IndexConfig in project hazelcast by hazelcast.

the class ClientMapProxy method addIndex.

@Override
public void addIndex(IndexConfig indexConfig) {
    checkNotNull(indexConfig, "Index config cannot be null.");
    IndexConfig indexConfig0 = IndexUtils.validateAndNormalize(name, indexConfig);
    ClientMessage request = MapAddIndexCodec.encodeRequest(name, indexConfig0);
    invoke(request);
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Aggregations

IndexConfig (com.hazelcast.config.IndexConfig)130 Test (org.junit.Test)49 QuickTest (com.hazelcast.test.annotation.QuickTest)45 Config (com.hazelcast.config.Config)42 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)38 MapConfig (com.hazelcast.config.MapConfig)34 HazelcastInstance (com.hazelcast.core.HazelcastInstance)29 ArrayList (java.util.ArrayList)16 Before (org.junit.Before)13 MapStoreConfig (com.hazelcast.config.MapStoreConfig)12 InternalIndex (com.hazelcast.query.impl.InternalIndex)12 AttributeConfig (com.hazelcast.config.AttributeConfig)9 MapContainer (com.hazelcast.map.impl.MapContainer)9 IndexRangeFilter (com.hazelcast.sql.impl.exec.scan.index.IndexRangeFilter)9 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)8 Node (org.w3c.dom.Node)8 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)7 IMap (com.hazelcast.map.IMap)7 Indexes (com.hazelcast.query.impl.Indexes)7 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)7