public static <K, V> PTable<K, Collection<V>> collectValues(PTable<K, V> collect) { PTypeFamily tf = collect.getTypeFamily(); final PType<V> valueType = collect.getValueType(); return collect.groupByKey().mapValues("collect", new MapFn<Iterable<V>, Collection<V>>() { @Override public void initialize() { valueType.initialize(getConfiguration()); } public Collection<V> map(Iterable<V> values) { List<V> collected = Lists.newArrayList(); for (V value : values) { collected.add(valueType.getDetachedValue(value)); } return collected; } }, tf.collections(collect.getValueType())); }
return grouped.mapValues("cogroup", new PostGroupFn<T>(tupleFactory, ptypes), outputType);