Add PTable.values() method that returns a PCollection made up of the values in the table #23

Merged
merged 5 commits into from May 10, 2012

Projects

None yet

2 participants

@tzolov

The new PCollection.by(...) method converts collection into table. To compliment this method I have added the reverse method PTable.values() that returns collection of the values in the table. This should streamline/complete the syntax. For example one can sort a collection of complex Avro types by an arbitrary attribute like this:

PCollection unsorted = ...

MapFn nameExtractor = new MapFn() {
public String map(Person input) { return input.getName().toString(); }
};

PCollection sortedByName = unsorted .by(nameExtractor, strings()).groupByKey().ungroup().values();

AvroTypeSortTest.java test the values method.

@jwills

Love it, thank you! Would you mind adding keys() as well, as long as we're at it?

on the way

@jwills jwills merged commit d5103ae into cloudera:master May 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment