Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlapMap error ? #1

Open
Maatary opened this issue Mar 6, 2017 · 1 comment
Open

FlapMap error ? #1

Maatary opened this issue Mar 6, 2017 · 1 comment

Comments

@Maatary
Copy link

Maatary commented Mar 6, 2017

Hi,

I do not understand that line:

source.flatMapValues(value-> Arrays.asList(pattern.split(value.toLowerCase()))).map((key, value) -> new KeyValue<Object, Object>(value, value))

In fact, the map is confusing because it expect a pair. value-> Arrays.asList(pattern.split(value.toLowerCase()))). is supposed to return a list of word not list pair. Hence i do not understand the chaining here.

Please can you explain that ?

@gwenshap
Copy link
Owner

pattern.split will return an array (http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#split(java.lang.CharSequence))

I'm converting it to a list. Flatmap takes the stream of lists (or any other iterable), flattens it into a stream of events and applies the mapping (turning each (key, value) into (value,value)).

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants