Search in sources :

Example 76 with IndexConfig

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

the class MapScanMigrationStressTest method stressTest_sortedIndex.

@Test(timeout = 600_000)
public void stressTest_sortedIndex() throws InterruptedException {
    List<Row> expected = new ArrayList<>();
    Map<Integer, Integer> temp = new HashMap<>();
    for (int i = 0; i <= ITEM_COUNT; i++) {
        temp.put(i, i);
        expected.add(new Row(ITEM_COUNT - i, ITEM_COUNT - i));
    }
    map.putAll(temp);
    IndexConfig indexConfig = new IndexConfig(IndexType.SORTED, "this").setName(randomName());
    map.addIndex(indexConfig);
    mutator = new MutatorThread(2000L);
    assertRowsOrdered("SELECT * FROM " + MAP_NAME + " ORDER BY this DESC", expected, mutator);
    mutator.terminate();
    mutator.join();
    assertThat(mutatorException.get()).isNull();
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SqlRow(com.hazelcast.sql.SqlRow) Row(com.hazelcast.jet.sql.SqlTestSupport.Row) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 77 with IndexConfig

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

the class MapScanMigrationStressTest method stressTest_hashIndex.

@Test(timeout = 600_000)
public void stressTest_hashIndex() throws InterruptedException {
    List<Row> expected = new ArrayList<>();
    Map<Integer, Integer> temp = new HashMap<>();
    for (int i = 0; i <= ITEM_COUNT / 5; i++) {
        temp.put(i, 1);
        expected.add(new Row(i, 1));
    }
    map.putAll(temp);
    IndexConfig indexConfig = new IndexConfig(IndexType.HASH, "this").setName(randomName());
    map.addIndex(indexConfig);
    mutator = new MutatorThread(2000L);
    // Awful performance of such a query, but still a good load for test.
    assertRowsAnyOrder("SELECT * FROM " + MAP_NAME + " WHERE this = 1", expected, mutator);
    mutator.terminate();
    mutator.join();
    assertThat(mutatorException.get()).isNull();
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SqlRow(com.hazelcast.sql.SqlRow) Row(com.hazelcast.jet.sql.SqlTestSupport.Row) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 78 with IndexConfig

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

the class QueryCacheXmlConfigBuilderHelper method queryCacheIndexesHandle.

protected void queryCacheIndexesHandle(Node n, QueryCacheConfig queryCacheConfig) {
    for (Node indexNode : childElements(n)) {
        if (matches("index", cleanNodeName(indexNode))) {
            IndexConfig indexConfig = IndexUtils.getIndexConfigFromXml(indexNode, domLevel3, strict);
            queryCacheConfig.addIndexConfig(indexConfig);
        }
    }
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) Node(org.w3c.dom.Node)

Example 79 with IndexConfig

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

the class SqlOrderByTest method addIndex.

private void addIndex(List<String> fieldNames, IndexType type, String mapName) {
    IMap<Object, AbstractPojo> map = getTarget().getMap(mapName);
    IndexConfig indexConfig = new IndexConfig().setName("Index_" + randomName()).setType(type);
    for (String fieldName : fieldNames) {
        indexConfig.addAttribute(fieldName);
    }
    map.addIndex(indexConfig);
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) AbstractPojo(com.hazelcast.jet.sql.SqlBasicTest.AbstractPojo)

Example 80 with IndexConfig

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

the class SqlOrderByTest method checkSelectWithOrderBy.

private void checkSelectWithOrderBy(List<String> indexAttrs, String sql, List<String> checkOrderFields, List<Boolean> orderDirections) {
    IMap<Object, AbstractPojo> map = getTarget().getMap(mapName());
    IndexConfig indexConfig = new IndexConfig().setName("Index_" + randomName()).setType(SORTED);
    for (String indexAttr : indexAttrs) {
        indexConfig.addAttribute(indexAttr);
    }
    map.addIndex(indexConfig);
    assertEquals(DATA_SET_SIZE, map.size());
    assertSqlResultOrdered(sql, checkOrderFields, orderDirections, map.size());
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) AbstractPojo(com.hazelcast.jet.sql.SqlBasicTest.AbstractPojo)

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