25 lines
628 B
Text
25 lines
628 B
Text
|
|
F hash_join(table1, table2)
|
|||
|
|
DefaultDict[String, [(Int, String)]] h
|
|||
|
|
L(s) table1
|
|||
|
|
h[s[1]].append(s)
|
|||
|
|
|
|||
|
|
[((Int, String), (String, String))] res
|
|||
|
|
L(r) table2
|
|||
|
|
L(s) h[r[0]]
|
|||
|
|
res [+]= (s, r)
|
|||
|
|
R res
|
|||
|
|
|
|||
|
|
V table1 = [(27, ‘Jonah’),
|
|||
|
|
(18, ‘Alan’),
|
|||
|
|
(28, ‘Glory’),
|
|||
|
|
(18, ‘Popeye’),
|
|||
|
|
(28, ‘Alan’)]
|
|||
|
|
V table2 = [(‘Jonah’, ‘Whales’),
|
|||
|
|
(‘Jonah’, ‘Spiders’),
|
|||
|
|
(‘Alan’, ‘Ghosts’),
|
|||
|
|
(‘Alan’, ‘Zombies’),
|
|||
|
|
(‘Glory’, ‘Buffy’)]
|
|||
|
|
|
|||
|
|
L(row) hash_join(table1, table2)
|
|||
|
|
print(row)
|