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));
}
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));
}
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);
}
}
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);
}
};
}
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());
}
};
}
Aggregations