Search in sources :

Example 6 with MapAttributeConfig

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

the class ExtractorsTest method getGetter_extractor_cachingWorks.

@Test
public void getGetter_extractor_cachingWorks() {
    // GIVEN
    MapAttributeConfig config = new MapAttributeConfig("gimmePower", "com.hazelcast.query.impl.getters.ExtractorsTest$PowerExtractor");
    Extractors extractors = new Extractors(asList(config), useClassloader ? this.getClass().getClassLoader() : null);
    // WHEN
    Getter getterFirstInvocation = extractors.getGetter(UNUSED, bond, "gimmePower");
    Getter getterSecondInvocation = extractors.getGetter(UNUSED, bond, "gimmePower");
    // THEN
    assertThat(getterFirstInvocation, sameInstance(getterSecondInvocation));
    assertThat(getterFirstInvocation, instanceOf(ExtractorGetter.class));
}
Also used : MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) Test(org.junit.Test)

Example 7 with MapAttributeConfig

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

the class ExtractorsTest method extract_extractor_correctValue.

@Test
public void extract_extractor_correctValue() {
    // GIVEN
    MapAttributeConfig config = new MapAttributeConfig("gimmePower", "com.hazelcast.query.impl.getters.ExtractorsTest$PowerExtractor");
    Extractors extractors = new Extractors(asList(config), useClassloader ? this.getClass().getClassLoader() : null);
    // WHEN
    Object power = extractors.extract(UNUSED, bond, "gimmePower");
    // THEN
    assertThat((Integer) power, equalTo(550));
}
Also used : MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) Test(org.junit.Test)

Example 8 with MapAttributeConfig

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

the class QueryPerformanceTest method setup.

@Setup
public void setup() throws IOException {
    Config config = new Config();
    config.getSerializationConfig().addPortableFactory(DefaultPortableReaderQuickTest.TestPortableFactory.ID, new DefaultPortableReaderQuickTest.TestPortableFactory());
    //
    // object map
    //
    MapAttributeConfig nameWithExtractor = new MapAttributeConfig();
    nameWithExtractor.setName("nameWithExtractor");
    nameWithExtractor.setExtractor("com.hazelcast.query.impl.QueryPerformanceTest$NameExtractor");
    MapAttributeConfig limbNameWithExtractor = new MapAttributeConfig();
    limbNameWithExtractor.setName("limbNameWithExtractor");
    limbNameWithExtractor.setExtractor("com.hazelcast.query.impl.QueryPerformanceTest$LimbNameExtractor");
    MapConfig objectMapConfig = new MapConfig();
    objectMapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
    objectMapConfig.setName("objectMap");
    MapConfig objectMapWithExtractorConfig = new MapConfig();
    objectMapWithExtractorConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
    objectMapWithExtractorConfig.setName("objectMapWithExtractor");
    objectMapWithExtractorConfig.addMapAttributeConfig(nameWithExtractor);
    objectMapWithExtractorConfig.addMapAttributeConfig(limbNameWithExtractor);
    //
    // portable map
    //
    MapAttributeConfig portableNameWithExtractor = new MapAttributeConfig();
    portableNameWithExtractor.setName("nameWithExtractor");
    portableNameWithExtractor.setExtractor("com.hazelcast.query.impl.QueryPerformanceTest$PortableNameExtractor");
    MapAttributeConfig portableLimbNameWithExtractor = new MapAttributeConfig();
    portableLimbNameWithExtractor.setName("limbNameWithExtractor");
    portableLimbNameWithExtractor.setExtractor("com.hazelcast.query.impl.QueryPerformanceTest$PortableLimbNameExtractor");
    MapConfig portableMapConfig = new MapConfig();
    portableMapConfig.setName("portableMapWithExtractor");
    portableMapConfig.addMapAttributeConfig(portableNameWithExtractor);
    portableMapConfig.addMapAttributeConfig(portableLimbNameWithExtractor);
    config.addMapConfig(objectMapConfig);
    config.addMapConfig(objectMapWithExtractorConfig);
    config.addMapConfig(portableMapConfig);
    hz = (HazelcastInstanceProxy) createHazelcastInstance(config);
    portableMap = hz.getMap("portableMap");
    objectMap = hz.getMap("objectMap");
    objectMapWithExtractor = hz.getMap("objectMapWithExtractor");
    portableMapWithExtractor = hz.getMap("portableMapWithExtractor");
    ComplexDataStructure.Person BOND = person("Bond", limb("left-hand", tattoos(), finger("thumb"), finger(null)), limb("right-hand", tattoos("knife"), finger("middle"), finger("index")));
    for (int i = 0; i <= 1000; i++) {
        portableMap.put(String.valueOf(i), BOND.getPortable());
        portableMapWithExtractor.put(String.valueOf(i), BOND.getPortable());
        objectMap.put(String.valueOf(i), BOND);
        objectMapWithExtractor.put(String.valueOf(i), BOND);
    }
}
Also used : MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) DefaultPortableReaderQuickTest(com.hazelcast.nio.serialization.impl.DefaultPortableReaderQuickTest) ComplexDataStructure(com.hazelcast.query.impl.extractor.specification.ComplexDataStructure) MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) Setup(org.openjdk.jmh.annotations.Setup)

Example 9 with MapAttributeConfig

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

the class CollectionAllPredicatesExtractorTest method getInstanceConfigurator.

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

        @Override
        public void doWithConfig(Config config, Multivalue mv) {
            MapConfig mapConfig = config.getMapConfig("map");
            MapAttributeConfig reducedNameAttribute = new AbstractExtractionTest.TestMapAttributeIndexConfig();
            reducedNameAttribute.setName(AbstractExtractionTest.parametrize("limb_[any].name", mv));
            reducedNameAttribute.setExtractor("com.hazelcast.query.impl.extractor.predicates.CollectionAllPredicatesExtractorTest$ReducedLimbNameExtractor");
            mapConfig.addMapAttributeConfig(reducedNameAttribute);
            MapAttributeConfig indexOneNameAttribute = new AbstractExtractionTest.TestMapAttributeIndexConfig();
            indexOneNameAttribute.setName(AbstractExtractionTest.parametrize("limb_[1].name", mv));
            indexOneNameAttribute.setExtractor("com.hazelcast.query.impl.extractor.predicates.CollectionAllPredicatesExtractorTest$IndexOneLimbNameExtractor");
            mapConfig.addMapAttributeConfig(indexOneNameAttribute);
            MapAttributeConfig reducedPowerAttribute = new AbstractExtractionTest.TestMapAttributeIndexConfig();
            reducedPowerAttribute.setName(AbstractExtractionTest.parametrize("limb_[any].power", mv));
            reducedPowerAttribute.setExtractor("com.hazelcast.query.impl.extractor.predicates.CollectionAllPredicatesExtractorTest$ReducedLimbPowerExtractor");
            mapConfig.addMapAttributeConfig(reducedPowerAttribute);
            MapAttributeConfig indexOnePowerAttribute = new AbstractExtractionTest.TestMapAttributeIndexConfig();
            indexOnePowerAttribute.setName(AbstractExtractionTest.parametrize("limb_[1].power", mv));
            indexOnePowerAttribute.setExtractor("com.hazelcast.query.impl.extractor.predicates.CollectionAllPredicatesExtractorTest$IndexOneLimbPowerExtractor");
            mapConfig.addMapAttributeConfig(indexOnePowerAttribute);
        }
    };
}
Also used : MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) MapConfig(com.hazelcast.config.MapConfig)

Example 10 with MapAttributeConfig

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

the class ExtractionWithExtractorsSpecTest method getInstanceConfigurator.

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

        @Override
        public void doWithConfig(Config config, AbstractExtractionTest.Multivalue mv) {
            MapConfig mapConfig = config.getMapConfig("map");
            MapAttributeConfig tattoosCount = new AbstractExtractionTest.TestMapAttributeIndexConfig();
            tattoosCount.setName("tattoosCount");
            tattoosCount.setExtractor("com.hazelcast.query.impl.extractor.specification.ExtractionWithExtractorsSpecTest$LimbTattoosCountExtractor");
            mapConfig.addMapAttributeConfig(tattoosCount);
            config.getSerializationConfig().addPortableFactory(ComplexDataStructure.PersonPortableFactory.ID, new ComplexDataStructure.PersonPortableFactory());
        }
    };
}
Also used : MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig)

Aggregations

MapAttributeConfig (com.hazelcast.config.MapAttributeConfig)17 Test (org.junit.Test)12 Config (com.hazelcast.config.Config)5 MapConfig (com.hazelcast.config.MapConfig)5 ValueExtractor (com.hazelcast.query.extractor.ValueExtractor)3 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)1 MapIndexConfig (com.hazelcast.config.MapIndexConfig)1 MapPartitionLostListenerConfig (com.hazelcast.config.MapPartitionLostListenerConfig)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)1 WanReplicationRef (com.hazelcast.config.WanReplicationRef)1 DefaultPortableReaderQuickTest (com.hazelcast.nio.serialization.impl.DefaultPortableReaderQuickTest)1 ComplexDataStructure (com.hazelcast.query.impl.extractor.specification.ComplexDataStructure)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Setup (org.openjdk.jmh.annotations.Setup)1