@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)); } }