use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.
the class EntryProcessorTest method testExecuteOnKeysBackupOperationIndexed.
/**
* Reproducer for https://github.com/hazelcast/hazelcast/issues/1854
* This one with index which results in an exception.
*/
@Test
public void testExecuteOnKeysBackupOperationIndexed() {
Config cfg = getConfig();
cfg.getMapConfig(MAP_NAME).setBackupCount(1).addMapIndexConfig(new MapIndexConfig("attr1", false));
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(cfg);
HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(cfg);
IMap<String, TestData> map = instance1.getMap(MAP_NAME);
map.put("a", new TestData("foo", "bar"));
map.put("b", new TestData("abc", "123"));
map.executeOnKeys(map.keySet(), new TestDeleteEntryProcessor());
// the entry has been removed from the primary store but not the backup,
// so let's kill the primary and execute the logging processor again
HazelcastInstance newPrimary;
String aMemberUiid = instance1.getPartitionService().getPartition("a").getOwner().getUuid();
if (aMemberUiid.equals(instance1.getCluster().getLocalMember().getUuid())) {
instance1.shutdown();
newPrimary = instance2;
} else {
instance2.shutdown();
newPrimary = instance1;
}
// make sure there are no entries left
IMap<String, TestData> map2 = newPrimary.getMap("test");
Map<String, Object> executedEntries = map2.executeOnEntries(new TestLoggingEntryProcessor());
assertEquals(0, executedEntries.size());
}
use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.
the class EntryProcessorTest method setupImapForEntryProcessorWithIndex.
private IMap<Long, MyData> setupImapForEntryProcessorWithIndex() {
Config config = getConfig();
MapConfig testMapConfig = config.getMapConfig(MAP_NAME);
testMapConfig.setInMemoryFormat(inMemoryFormat);
testMapConfig.getMapIndexConfigs().add(new MapIndexConfig("lastValue", true));
HazelcastInstance instance = createHazelcastInstance(config);
return instance.getMap(MAP_NAME);
}
use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.
the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withIndex.
@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withIndex() {
String mapName = "default";
Config config = getConfig();
config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {
public Portable create(int classId) {
return new PortableEmployee();
}
});
config.getMapConfig(mapName).addMapIndexConfig(new MapIndexConfig("notExist", false)).addMapIndexConfig(new MapIndexConfig("n", false));
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
for (int i = 0; i < 5; i++) {
map.put(i, new PortableEmployee(i, "name_" + i));
}
Collection values = map.values(new SqlPredicate("n = name_2 OR notExist = name_0"));
assertEquals(1, values.size());
}
use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.
the class QueryBasicTest method testQueryUsingNestedPortableObjectWithIndex.
@Test
public void testQueryUsingNestedPortableObjectWithIndex() {
String name = randomMapName();
Config config = getConfig();
config.addMapConfig(new MapConfig(name).addMapIndexConfig(new MapIndexConfig("child.timestamp", false)).addMapIndexConfig(new MapIndexConfig("child.child.timestamp", true)));
testQueryUsingNestedPortableObject(config, name);
}
use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.
the class IndexIntegrationTest method putRemove_withIndex_whereAttributeIsNull.
@Test
public void putRemove_withIndex_whereAttributeIsNull() {
// GIVEN
MapIndexConfig mapIndexConfig = new MapIndexConfig();
mapIndexConfig.setAttribute("amount");
mapIndexConfig.setOrdered(false);
MapConfig mapConfig = new MapConfig().setName("map");
mapConfig.addMapIndexConfig(mapIndexConfig);
Config config = new Config();
config.addMapConfig(mapConfig);
Trade trade = new Trade();
trade.setCurrency("EUR");
trade.setAmount(null);
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, Trade> map = instance.getMap("map");
// WHEN
map.put(1, trade);
map.remove(1);
EntryObject e = new PredicateBuilder().getEntryObject();
Predicate predicate = e.get("amount").isNull();
Collection<Trade> values = map.values(predicate);
// THEN
assertEquals(0, values.size());
assertNull(map.get(1));
}
Aggregations