private Map<TestData.Key, Collection<TestData.Value>> collectData(Generator iter, int num) throws Exception { Map<TestData.Key, Collection<TestData.Value>> map = new HashMap<TestData.Key, Collection<TestData.Value>>(); Record pair = new Record(); for (int i = 0; i < num; i++) { iter.next(pair); TestData.Key key = pair.getField(0, TestData.Key.class); if (!map.containsKey(key)) { map.put(new TestData.Key(key.getKey()), new ArrayList<TestData.Value>()); } Collection<TestData.Value> values = map.get(key); values.add(new TestData.Value(pair.getField(1, TestData.Value.class).getValue())); } return map; }