Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,15 @@
def hashJoin(table1, col1, table2, col2) {
def hashed = table1.groupBy { s -> s[col1] }
def q = [] as Set
table2.each { r ->
def join = hashed[r[col2]]
join.each { s ->
q << s.plus(r)
}
}
q
}

View file

@ -0,0 +1,8 @@
def hashJoin(table1, col1, table2, col2) {
def hashed = table1.groupBy { s -> s[col1] }
table2.collect { r ->
hashed[r[col2]].collect { s -> s.plus(r) }
}.flatten()
}

View file

@ -0,0 +1,13 @@
def s = [[age: 27, name: 'Jonah'],
[age: 18, name: 'Alan'],
[age: 28, name: 'Glory'],
[age: 18, name: 'Popeye'],
[age: 28, name: 'Alan']]
def r = [[name: 'Jonah', nemesis: 'Whales'],
[name: 'Jonah', nemesis: 'Spiders'],
[name: 'Alan', nemesis: 'Ghosts'],
[name: 'Alan', nemesis: 'Zombies'],
[name: 'Glory', nemesis: 'Buffy']]
hashJoin(s, "name", r, "name").sort {it.name}.each { println it }