Created
July 27, 2014 17:32
-
-
Save hgmiguel/e847aac977b6bd2b1e59 to your computer and use it in GitHub Desktop.
Collection Pipeline in groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
some_articles | |
.collectMany{article -> article.tags.collect{ [ ( it ), article] }} | |
.groupBy{it.first()} | |
.collectEntries {k,v -> [( k ): v.collect {it.last()}]} | |
.collect {k,v -> [( k ):[articles: v.size(),words:v.collect{it.words}.inject(0) { acc, val -> acc + val }] ]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment