use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorsAndIndexesTest method testExtractorsAreRespectedByEntriesReturnedFromIndexes.
@Test
public void testExtractorsAreRespectedByEntriesReturnedFromIndexes() {
String mapName = randomMapName();
Config config = new Config();
config.getMapConfig(mapName).setInMemoryFormat(inMemoryFormat).addIndexConfig(new IndexConfig(IndexType.SORTED, "last")).addAttributeConfig(new AttributeConfig("generated", Extractor.class.getName()));
config.getNativeMemoryConfig().setEnabled(true);
config.setProperty(ClusterProperty.PARTITION_COUNT.getName(), "1");
config.setProperty(QueryEngineImpl.DISABLE_MIGRATION_FALLBACK.getName(), "true");
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, Person> map = instance.getMap(mapName);
populateMap(map);
// this predicate queries the index
Predicate lastPredicate = equal("last", "last");
// this predicate is not indexed and acts on the entries returned from
// the index which must support extractors otherwise this test will fail
Predicate alwaysFirst = equal("generated", "first");
Predicate composed = Predicates.and(lastPredicate, alwaysFirst);
Collection<Person> values = map.values(composed);
assertEquals(100, values.size());
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_accessException.
@Test
public void instantiate_extractors_accessException() {
// GIVEN
AttributeConfig string = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$AccessExceptionExtractor");
// EXPECT
expected.expect(IllegalArgumentException.class);
// WHEN
instantiateExtractors(singletonList(string));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors.
@Test
public void instantiate_extractors() {
// GIVEN
AttributeConfig iqExtractor = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
AttributeConfig nameExtractor = new AttributeConfig("name", "com.hazelcast.query.impl.getters.ExtractorHelperTest$NameExtractor");
// WHEN
Map<String, ValueExtractor> extractors = instantiateExtractors(asList(iqExtractor, nameExtractor));
// THEN
assertThat(extractors.get("iq"), instanceOf(IqExtractor.class));
assertThat(extractors.get("name"), instanceOf(NameExtractor.class));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractor.
@Test
public void instantiate_extractor() {
// GIVEN
AttributeConfig config = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
// WHEN
ValueExtractor extractor = instantiateExtractor(config);
// THEN
assertThat(extractor, instanceOf(IqExtractor.class));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_duplicateExtractor.
@Test
public void instantiate_extractors_duplicateExtractor() {
// GIVEN
AttributeConfig iqExtractor = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
AttributeConfig iqExtractorDuplicate = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
// EXPECT
expected.expect(IllegalArgumentException.class);
// WHEN
instantiateExtractors(asList(iqExtractor, iqExtractorDuplicate));
}
Aggregations