Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Hash-join/Mathematica/hash-join.math
Normal file
10
Task/Hash-join/Mathematica/hash-join.math
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
hashJoin[table1_List,table1colindex_Integer,table2_List,table2colindex_Integer]:=Module[{h,f,t1,t2,tmp},
|
||||
t1=If[table1colindex != 1,table1[[All,Prepend[Delete[Range@Length@table1[[1]],table1colindex],table1colindex]]],table1];
|
||||
t2=If[table2colindex != 1, table2[[All,Prepend[Delete[Range@Length@table2[[1]],table2colindex],table2colindex]]],table2];
|
||||
|
||||
If[Length[t1]>Length[t2],tmp=t1;t1=t2;t2=tmp;];
|
||||
h= GroupBy[t1,First];
|
||||
f[{a_,b_List}]:={a,#}&/@b;
|
||||
Partition[Flatten[Map[f,{#[[2;;]],h[#[[1]]]}&/@t2
|
||||
]],Length[t1[[1]]]+Length[t2[[1]]]-1]
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue