Search in sources :

Example 1 with AttributeConfig

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

the class DynamicConfigXmlGenerator method attributeConfigXmlGenerator.

private static void attributeConfigXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, MapConfig m) {
    if (!m.getAttributeConfigs().isEmpty()) {
        gen.open("attributes");
        for (AttributeConfig attributeCfg : m.getAttributeConfigs()) {
            gen.node("attribute", attributeCfg.getName(), "extractor-class-name", attributeCfg.getExtractorClassName());
        }
        gen.close();
    }
}
Also used : AttributeConfig(com.hazelcast.config.AttributeConfig)

Example 2 with AttributeConfig

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

the class MemberDomConfigProcessor method attributesHandle.

protected void attributesHandle(Node n, MapConfig mapConfig) {
    for (Node extractorNode : childElements(n)) {
        if (matches("attribute", cleanNodeName(extractorNode))) {
            String extractor = getTextContent(getNamedItemNode(extractorNode, "extractor-class-name"));
            String name = getTextContent(extractorNode);
            mapConfig.addAttributeConfig(new AttributeConfig(name, extractor));
        }
    }
}
Also used : Node(org.w3c.dom.Node) AttributeConfig(com.hazelcast.config.AttributeConfig)

Example 3 with AttributeConfig

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

the class ExtractorsTest method getGetter_extractor_cachingWorks.

@Test
public void getGetter_extractor_cachingWorks() {
    // GIVEN
    AttributeConfig config = new AttributeConfig("gimmePower", "com.hazelcast.query.impl.getters.ExtractorsTest$PowerExtractor");
    Extractors extractors = createExtractors(config);
    // WHEN
    Getter getterFirstInvocation = extractors.getGetter(bond, "gimmePower", true);
    Getter getterSecondInvocation = extractors.getGetter(bond, "gimmePower", true);
    // THEN
    assertThat(getterFirstInvocation, sameInstance(getterSecondInvocation));
    assertThat(getterFirstInvocation, instanceOf(ExtractorGetter.class));
}
Also used : AttributeConfig(com.hazelcast.config.AttributeConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with AttributeConfig

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

the class QueryCacheTest method testQueryCache_with_attribute_inPredicate.

@Test
public void testQueryCache_with_attribute_inPredicate() {
    String ATTRIBUTE_NAME = "booleanAttribute";
    Config config = new Config();
    config.getMapConfig(mapName).addQueryCacheConfig(new QueryCacheConfig(cacheName).setIncludeValue(true).setPredicateConfig(new PredicateConfig(Predicates.equal(ATTRIBUTE_NAME, true)))).addAttributeConfig(new AttributeConfig().setExtractorClassName(EvenNumberEmployeeValueExtractor.class.getName()).setName(ATTRIBUTE_NAME));
    IMap<Integer, Employee> map = getIMap(config);
    QueryCache<Integer, Employee> queryCache = map.getQueryCache(cacheName);
    populateMap(map, 100);
    assertQueryCacheSizeEventually(50, queryCache);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Employee(com.hazelcast.map.impl.querycache.utils.Employee) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) Config(com.hazelcast.config.Config) PredicateConfig(com.hazelcast.config.PredicateConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with AttributeConfig

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

the class SingleValueAllPredicatesExtractorTest method getInstanceConfigurator.

@Override
protected AbstractExtractionTest.Configurator getInstanceConfigurator() {
    return new AbstractExtractionTest.Configurator() {

        @Override
        public void doWithConfig(Config config, Multivalue mv) {
            MapConfig mapConfig = config.getMapConfig("map");
            AttributeConfig iqConfig = new TestAttributeIndexConfig();
            iqConfig.setName("brain.iq");
            iqConfig.setExtractorClassName("com.hazelcast.query.impl.extractor.predicates.SingleValueAllPredicatesExtractorTest$IqExtractor");
            mapConfig.addAttributeConfig(iqConfig);
            AttributeConfig nameConfig = new TestAttributeIndexConfig();
            nameConfig.setName("brain.name");
            nameConfig.setExtractorClassName("com.hazelcast.query.impl.extractor.predicates.SingleValueAllPredicatesExtractorTest$NameExtractor");
            mapConfig.addAttributeConfig(nameConfig);
        }
    };
}
Also used : Config(com.hazelcast.config.Config) AttributeConfig(com.hazelcast.config.AttributeConfig) MapConfig(com.hazelcast.config.MapConfig) MapConfig(com.hazelcast.config.MapConfig) AttributeConfig(com.hazelcast.config.AttributeConfig)

Aggregations

AttributeConfig (com.hazelcast.config.AttributeConfig)31 QuickTest (com.hazelcast.test.annotation.QuickTest)17 Test (org.junit.Test)17 MapConfig (com.hazelcast.config.MapConfig)11 Config (com.hazelcast.config.Config)9 IndexConfig (com.hazelcast.config.IndexConfig)9 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)6 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)4 EventJournalConfig (com.hazelcast.config.EventJournalConfig)4 EvictionConfig (com.hazelcast.config.EvictionConfig)4 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)4 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)4 MultiMapConfig (com.hazelcast.config.MultiMapConfig)4 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 AwsConfig (com.hazelcast.config.AwsConfig)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)3 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)3 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3