the server operations of the search algorithm for MJXT @param join_tokens1 joinToken(1) in JXT @param join_tokens2 joinToken(1) in JXT @param join_column the chosen column of the join attribute @return the matching result (the records of the all tables satisfy the query)
(ArrayList<byte[][]> join_tokens1, ArrayList<byte[][]> join_tokens2, int join_column)
| 54 | * @return the matching result (the records of the all tables satisfy the query) |
| 55 | */ |
| 56 | public ArrayList<ArrayList<byte[]>> search(ArrayList<byte[][]> join_tokens1, ArrayList<byte[][]> join_tokens2, int join_column) { |
| 57 | ArrayList<ArrayList<byte[]>> res = new ArrayList<>(); |
| 58 | ArrayList<ArrayList<tuple>> tsets = new ArrayList<>(); |
| 59 | for (int i = 0; i < table_num; i++) { |
| 60 | tsets.add(tset.get(stag[i])); |
| 61 | } |
| 62 | ArrayList<tuple> tset_each1 = tsets.get(0); |
| 63 | Map<tuple, ArrayList<ArrayList<tuple>>> satisfy_tseti = new LinkedHashMap<>(); |
| 64 | for (int i = 1; i < table_num; i++) { |
| 65 | ArrayList<tuple> tset_eachi = tsets.get(i); |
| 66 | byte[][] xtoken1 = new byte[tset_each1.size()][]; |
| 67 | byte[][] xtokeni = new byte[tset_eachi.size()][]; |
| 68 | byte[][] join_token_1_i = join_tokens1.get(i - 1); |
| 69 | byte[][] join_token_i_1 = join_tokens2.get(i - 1); |
| 70 | for (int j = 0; j < join_token_1_i.length; j++) { |
| 71 | xtoken1[j] = tool.Xor(tset_each1.get(j).h_y[join_column], join_token_1_i[j]); |
| 72 | } |
| 73 | for (int j = 0; j < join_token_i_1.length; j++) { |
| 74 | xtokeni[j] = tool.Xor(tset_eachi.get(j).h_x[join_column], join_token_i_1[j]); |
| 75 | } |
| 76 | for (int j = 0; j < xtoken1.length; j++) { |
| 77 | int counter = 0; |
| 78 | for (int k = 0; k < xtokeni.length; k++) { |
| 79 | long x = tool.bytesToLong(tool.Xor(xtoken1[j], xtokeni[k])); |
| 80 | if (!f[i].mayContain(x)){ |
| 81 | counter++; |
| 82 | }else{ |
| 83 | if (!satisfy_tseti.containsKey(tset_each1.get(j)) && i == 1){ |
| 84 | ArrayList<ArrayList<tuple>> tablei = new ArrayList<>(); |
| 85 | ArrayList<tuple> tablei_tset = new ArrayList<>(); |
| 86 | tablei_tset.add(tset_eachi.get(k)); |
| 87 | tablei.add(tablei_tset); |
| 88 | satisfy_tseti.put(tset_each1.get(j), tablei); |
| 89 | }else { |
| 90 | ArrayList<ArrayList<tuple>> tablei = satisfy_tseti.get(tset_each1.get(j)); |
| 91 | ArrayList<tuple> tablei_tset = new ArrayList<>(); |
| 92 | tablei_tset.add(tset_eachi.get(k)); |
| 93 | tablei.add(tablei_tset); |
| 94 | satisfy_tseti.put(tset_each1.get(j), tablei); |
| 95 | } |
| 96 | } |
| 97 | if (counter == xtokeni.length){ |
| 98 | satisfy_tseti.remove(tset_each1.get(j)); |
| 99 | counter = 0; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | for (int i = 0; i < table_num; i++) { |
| 105 | ArrayList<byte[]> res_i = new ArrayList<>(); |
| 106 | res.add(res_i); |
| 107 | } |
| 108 | for (Map.Entry<tuple, ArrayList<ArrayList<tuple>>> entry : satisfy_tseti.entrySet()){ |
| 109 | res.get(0).add(entry.getKey().ct); |
| 110 | ArrayList<ArrayList<tuple>> res_tset = entry.getValue(); |
| 111 | for (int i = 1; i < table_num; i++) { |
| 112 | for (int j = 0; j < res_tset.size() / (table_num - 1); j++) { |
| 113 | ArrayList<tuple> res_i = res_tset.get((i - 1) * (table_num - 1) + j); |