java - Natural Join of two dimensional Arrays -


i'm trying implement same idea of natural join in database on 2 dimensional arrays, i'm trying if have

a={[a,b],[a',b']} , b={[b,c], [b',c],[b,c']}

the result of naturaljoin(a,b) should be:

result = {[a,b,c], [a,b,c'],[a',b',c]} 

so after find shared column b , compare in both arrays, how can combine rows? can please give me hints on how create joinedtableau don't know number of rows beginning of join, how can create dynamically?

this pseudo code:

int[][] array1; int[][] array2; int shared = prtiallyequalcolumn(array1,array2);            for(int = 0; <array1.length; i++)                         {                             for(int j = 0 ; j < array2.length; j++)                             {                                 if(array1[i][shared] == array2[j][shared])                                  {                                         for(int s = 0 ; s < shared; s++)                                         {                                             joinedtableau[joinedcountrow][s] = array1[i][s];                                         }                                         for(int y=shared+1; y<array2.length;y++)                                         {                                             joinedtableau[joinedcountrow][y] = array2[j][y];                                         }                                     }                                 }                             } 

i don't know you've done in code have hidden several implementations code presented here in question. giving algo :-

each column value of array1 must compared each row value of array2 produce natural join,only in case if equal, else not.

a1 = array1.countrow(); a2 = array1.countcolumn(); b1 = array2.countrow(); b2 = array2.countcolumn(); = j = 1; while(i<=a1) while(j<=b1) if(array1[i][a2]==array2[j][1]) // i've made array-indices start 1 // perform natural-join operation between array1[i]+array2[j]-common_element // iterate array next passes. 

if there mistake or unclear you,please notify me. luck code.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -