Join jash
Well, what form does your relationship take? Are they in a relational database? If so, just use a SQL JOIN - the DBMS will probably make a hash join, but you don't need to worry about that.
If they are not in a relational database, why not?
If some weird constraint prevents you from forming the best tool for the job, then yes, doing a hash join is as simple as putting each tuple in a hash table bound to the join attribute, then iterating over the elements of one and finding matches in friend. If all your data fits into main memory, that is.
a source to share
Here is his way to make a hash join in Java Your best bet is to hash one table A with a hashmap.
HashMap<Sting, Object[]> hash = new HashMap<String, Object[]>();
for (Object[] a : as) {
hash.put(a.a1, a);
}
Then loop into B using a hash and regroup the matched one.
ArrayList joined = new ArrayList();
for(Objec[] b : bs){
A a = hash.get(b.b1);
joined.add(new Object[]{a, b});
}
This will only work if each element of table A has a unique a1.
a source to share