// ignored due to: https://github.com/hazelcast/hazelcast/issues/5035 @Ignore @Test public void testMapLoaderLoadUpdatingIndex() throws Exception { final int nodeCount = 3; String mapName = randomString(); SampleIndexableObjectMapLoader loader = new SampleIndexableObjectMapLoader(); Config config = createMapConfig(mapName, loader); NodeBuilder nodeBuilder = new NodeBuilder(nodeCount, config).build(); HazelcastInstance node = nodeBuilder.getRandomNode(); IMap<Integer, SampleIndexableObject> map = node.getMap(mapName); for (int i = 0; i < 10; i++) { map.put(i, new SampleIndexableObject("My-" + i, i)); } final SqlPredicate predicate = new SqlPredicate("name='My-5'"); assertPredicateResultCorrect(map, predicate); map.destroy(); loader.preloadValues = true; node = nodeBuilder.getRandomNode(); map = node.getMap(mapName); assertLoadAllKeysCount(loader, 1); assertPredicateResultCorrect(map, predicate); }
@Test public void addIndex() { HazelcastClient hClient = getHazelcastClient(); IMap map = hClient.getMap("addIndex"); int size = 1000; for (int i = 0; i < size; i++) { map.put(String.valueOf(i), new Employee("name" + i, i, true, 0)); } EntryObject e = new PredicateBuilder().getEntryObject(); Predicate predicate = e.get("age").equal(23); long begin = Clock.currentTimeMillis(); Set<Entry<Object, Object>> set = map.entrySet(predicate); long timeWithoutIndex = Clock.currentTimeMillis() - begin; assertEquals(1, set.size()); assertEquals(size, map.size()); map.destroy(); map = hClient.getMap("addIndex"); map.addIndex("age", true); for (int i = 0; i < size; i++) { map.put(String.valueOf(i), new Employee("name" + i, i, true, 0)); } begin = Clock.currentTimeMillis(); set = map.entrySet(predicate); long timeWithIndex = Clock.currentTimeMillis() - begin; assertEquals(1, set.size()); assertEquals(size, map.size()); assertTrue(timeWithoutIndex > 2 * timeWithIndex); // map.addIndex("age", true); }
@Test public void putAllMany() { HazelcastClient hClient = getHazelcastClient(); IMap map = hClient.getMap("putAllMany"); int counter = 100; for (int j = 0; j < 4; j++, counter *= 10) { Map tempMap = new HashMap(); for (int i = 0; i < counter; i++) { tempMap.put(i, i); } map.putAll(tempMap); assertEquals(1, map.get(1)); } map.destroy(); }
@Test public void destroyMap() throws InterruptedException { HazelcastClient hClient = getHazelcastClient(); IMap map = hClient.getMap("destroy"); for (int i = 0; i < 100; i++) { assertNull(map.put(i, i)); assertEquals(i, map.get(i)); } IMap<Integer, Integer> map2 = hClient.getMap("destroy"); assertTrue(map == map2); assertTrue(map.getId().equals(map2.getId())); map.destroy(); // map2 = hClient.getMap("destroy"); // assertFalse(map == map2); for (int i = 0; i < 100; i++) { // assertNull(map2.get(i)); } }
@After public void after() { map.destroy(); }