Hash join: Difference between revisions

No edit summary
Line 445:
 
<lang Groovy>
def hashJoin(s, r, col) {
 
def hashed = s.groupBy { sItem -> sItem.name[col] }
 
def q = [] as Set
 
r.each { rItem ->
def join = hashed[rItem.name[col]]
join.each { sItem ->
q << sItem.plus(rItem)
Line 476:
[name: 'Glory', nemesis: 'Buffy']]
 
hashJoin(s, r, "name").sort {it.name}.each { println it }
</pre>
 
Anonymous user