Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hash join in java

Tags:

java

I have two relations A and B, both with all integer attributes (A {a1,a2,a3,...} B{b1,b2,b3,..}. How would I hash-join these two in java? The user will pick the two joining attributes. Do I make two hashtables and then proceed to join them?

like image 919
Bramble Avatar asked Aug 23 '26 23:08

Bramble


1 Answers

Well, what form do your relations have? Are they in a relational database? If so, just use an SQL JOIN - the DBMS will probably do a hash join, but you don't have to care about that.

If they're not in a relational database, why not?

If some weird constraint prevents you form using the best tool for the job then yes, doing a hash join is as simple as putting each tuple into a hashtable keyed on the join attribute and then iterating over the entries of one and looking up matches in the other. If all your data fits into main memory, that is.

like image 165
Michael Borgwardt Avatar answered Aug 26 '26 11:08

Michael Borgwardt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!