Search in sources :

Example 86 with IndexConfig

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

the class IndexUtils method getIndexConfigFromYaml.

public static IndexConfig getIndexConfigFromYaml(Node indexNode, boolean domLevel3, boolean strict) {
    NamedNodeMap attrs = indexNode.getAttributes();
    String name = getTextContent(attrs.getNamedItem("name"), domLevel3);
    if (name.isEmpty()) {
        name = null;
    }
    String typeStr = getTextContent(attrs.getNamedItem("type"), domLevel3);
    if (typeStr.isEmpty()) {
        typeStr = IndexConfig.DEFAULT_TYPE.name();
    }
    IndexType type = getIndexTypeFromXmlName(typeStr);
    IndexConfig res = new IndexConfig().setName(name).setType(type);
    Node attributesNode = attrs.getNamedItem("attributes");
    for (Node attributeNode : childElements(attributesNode)) {
        String attribute = attributeNode.getNodeValue();
        res.addAttribute(attribute);
    }
    if (type == IndexType.BITMAP) {
        Node optionsNode = childElementWithName(indexNode, "bitmap-index-options", strict);
        if (optionsNode != null) {
            Node uniqueKeyNode = childElementWithName(optionsNode, "unique-key", strict);
            String uniqueKeyText = getTextContent(uniqueKeyNode, domLevel3);
            String uniqueKey = isNullOrEmpty(uniqueKeyText) ? BitmapIndexOptions.DEFAULT_UNIQUE_KEY : uniqueKeyText;
            Node uniqueKeyTransformationNode = childElementWithName(optionsNode, "unique-key-transformation", strict);
            String uniqueKeyTransformationText = getTextContent(uniqueKeyTransformationNode, domLevel3);
            UniqueKeyTransformation uniqueKeyTransformation = isNullOrEmpty(uniqueKeyTransformationText) ? BitmapIndexOptions.DEFAULT_UNIQUE_KEY_TRANSFORMATION : UniqueKeyTransformation.fromName(uniqueKeyTransformationText);
            res.getBitmapIndexOptions().setUniqueKey(uniqueKey);
            res.getBitmapIndexOptions().setUniqueKeyTransformation(uniqueKeyTransformation);
        }
    }
    return res;
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) IndexConfig(com.hazelcast.config.IndexConfig) Node(org.w3c.dom.Node) IndexType(com.hazelcast.config.IndexType) UniqueKeyTransformation(com.hazelcast.config.BitmapIndexOptions.UniqueKeyTransformation)

Example 87 with IndexConfig

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

the class MapIndexInfo method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    mapName = in.readString();
    int size = in.readInt();
    for (int i = 0; i < size; i++) {
        IndexConfig indexConfig = in.readObject();
        indexConfigs.add(indexConfig);
    }
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig)

Example 88 with IndexConfig

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

the class AggregatorsSpecTest method getMapWithNodeCount.

protected <K, V> IMap<K, V> getMapWithNodeCount(int nodeCount, boolean parallelAccumulation, boolean useIndex) {
    if (nodeCount < 1) {
        throw new IllegalArgumentException("node count < 1");
    }
    MapConfig mapConfig = new MapConfig().setName("aggr").setInMemoryFormat(inMemoryFormat);
    if (useIndex) {
        mapConfig.addIndexConfig(new IndexConfig(IndexConfig.DEFAULT_TYPE, "fieldWeCanQuery"));
    }
    Config config = getConfig().setProperty(PARTITION_COUNT.getName(), String.valueOf(nodeCount)).setProperty(AGGREGATION_ACCUMULATION_PARALLEL_EVALUATION.getName(), String.valueOf(parallelAccumulation)).addMapConfig(mapConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
    HazelcastInstance instance = factory.newInstances(config)[0];
    return instance.getMap("aggr");
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 89 with IndexConfig

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

the class AbstractClientConfigBuilderTest method testQueryCacheFullConfig.

@Test
public void testQueryCacheFullConfig() throws Exception {
    QueryCacheConfig queryCacheClassPredicateConfig = fullClientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-class-name-predicate");
    QueryCacheConfig queryCacheSqlPredicateConfig = fullClientConfig.getQueryCacheConfigs().get("map-name").get("query-cache-sql-predicate");
    EntryListenerConfig entryListenerConfig = queryCacheClassPredicateConfig.getEntryListenerConfigs().get(0);
    assertEquals("query-cache-class-name-predicate", queryCacheClassPredicateConfig.getName());
    assertTrue(entryListenerConfig.isIncludeValue());
    assertFalse(entryListenerConfig.isLocal());
    assertEquals("com.hazelcast.examples.EntryListener", entryListenerConfig.getClassName());
    assertTrue(queryCacheClassPredicateConfig.isIncludeValue());
    assertEquals(1, queryCacheClassPredicateConfig.getBatchSize());
    assertEquals(16, queryCacheClassPredicateConfig.getBufferSize());
    assertEquals(0, queryCacheClassPredicateConfig.getDelaySeconds());
    EvictionConfig evictionConfig = queryCacheClassPredicateConfig.getEvictionConfig();
    assertEquals(EvictionPolicy.LRU, evictionConfig.getEvictionPolicy());
    assertEquals(MaxSizePolicy.ENTRY_COUNT, evictionConfig.getMaxSizePolicy());
    assertEquals(10000, evictionConfig.getSize());
    assertEquals("com.hazelcast.examples.MyEvictionComparator", evictionConfig.getComparatorClassName());
    assertEquals(InMemoryFormat.BINARY, queryCacheClassPredicateConfig.getInMemoryFormat());
    assertFalse(queryCacheClassPredicateConfig.isCoalesce());
    assertTrue(queryCacheClassPredicateConfig.isPopulate());
    assertFalse(queryCacheClassPredicateConfig.isSerializeKeys());
    for (IndexConfig indexConfig : queryCacheClassPredicateConfig.getIndexConfigs()) {
        assertEquals("name", indexConfig.getAttributes().get(0));
        assertFalse(indexConfig.getType() == IndexType.SORTED);
    }
    assertEquals("com.hazelcast.examples.ExamplePredicate", queryCacheClassPredicateConfig.getPredicateConfig().getClassName());
    assertEquals("query-cache-sql-predicate", queryCacheSqlPredicateConfig.getName());
    assertEquals("%age=40", queryCacheSqlPredicateConfig.getPredicateConfig().getSql());
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) Test(org.junit.Test) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest)

Example 90 with IndexConfig

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

the class QueryCache method addIndex.

/**
 * @see IMap#addIndex(IndexType, String...)
 */
default void addIndex(IndexType type, String... attributes) {
    IndexConfig config = IndexUtils.createIndexConfig(type, attributes);
    addIndex(config);
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig)

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