| 29 | private static String K_c = "6574b33984e7fb55"; |
| 30 | |
| 31 | public static void main(String[] args) { |
| 32 | //Step 1 prepare the parameters |
| 33 | //the number of attributes which aren't the join attribute in the table. |
| 34 | int key_colnum = 9; |
| 35 | //the number join attributes in the table. |
| 36 | int join_column = 1; |
| 37 | int record_num = (int) Math.pow(2, 16); |
| 38 | int table_num = 2;//the number of the queried tables |
| 39 | String condition = "_Lmax100";//the condition aims to choose different tables from dataset |
| 40 | int[][] l_max = new int[table_num][join_column]; |
| 41 | String[] keyword = new String[table_num]; |
| 42 | String[] join_attr = new String[table_num]; |
| 43 | //Step 2 begin to set up |
| 44 | System.out.println("---------------- JXT++ for different L_max -----------------"); |
| 45 | Setup_JXTpp[] table = new Setup_JXTpp[table_num]; |
| 46 | Map<BigInteger, ArrayList<byte[]>> tset = new LinkedHashMap<>(); |
| 47 | for (int i = 0; i < table_num; i++) { |
| 48 | table[i] = new Setup_JXTpp(i + 1, key_colnum, join_column, record_num, condition); |
| 49 | table[i].construct(); |
| 50 | tset.putAll(table[i].getTset()); |
| 51 | System.arraycopy(table[i].getL_max(), 0, l_max[i], 0, join_column); |
| 52 | } |
| 53 | System.out.println("L_max for table1 for the join attribute : " + Arrays.toString(l_max[0])); |
| 54 | System.out.println("L_max for table2 for the join attribute : " + Arrays.toString(l_max[1])); |
| 55 | |
| 56 | //Step 3 begin to search |
| 57 | |
| 58 | //query 10 join attributes which indicates different L_max {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}. |
| 59 | for (int v = 100; v <= 1000; v += 100) { |
| 60 | l_max[0][0] = v; |
| 61 | l_max[1][0] = v; |
| 62 | for (int i = 0; i < table_num; i++) { |
| 63 | keyword[i] = "keyword0" + "table" + (i + 1) + "_keyword_0_0"; |
| 64 | join_attr[i] = "join-attr0"; |
| 65 | } |
| 66 | System.out.println("--------- JXT++ search(L_max = " + l_max[0][0] + ") --------"); |
| 67 | long search_all = 0; |
| 68 | for (int x = 0; x < 1000; x++) {//run 1000 times |
| 69 | long search_start = System.nanoTime(); |
| 70 | //Step 3.1 compute the stag |
| 71 | BigInteger stag1 = new BigInteger(Hash.Get_SHA_256((K_token + keyword[0] + join_attr[0] + 1).getBytes(StandardCharsets.UTF_8))); |
| 72 | Server_JXTpp serverMMJXTpp = new Server_JXTpp(tset, table, stag1); |
| 73 | byte[] w_0 = Hash.Get_SHA_256((K_w + keyword[0]).getBytes(StandardCharsets.UTF_8)); |
| 74 | Map<Integer, byte[]> map_cnt = new LinkedHashMap<>(); |
| 75 | ArrayList<byte[][]> join_tokens = new ArrayList<>(); |
| 76 | for (int i = 0; i < table_num; i++) {//Step 3.2 compute the joinTokens |
| 77 | byte[] w_i = Hash.Get_SHA_256((K_wp + keyword[i]).getBytes(StandardCharsets.UTF_8)); |
| 78 | byte[] join_hash = Hash.Get_SHA_256((K_h + join_attr[i]).getBytes(StandardCharsets.UTF_8)); |
| 79 | byte[][] join_token = new byte[l_max[i][0]][]; |
| 80 | for (int j = 1; j <= l_max[i][0]; j++) { |
| 81 | byte[] cnt; |
| 82 | if (map_cnt.containsKey(j)) { |
| 83 | cnt = map_cnt.get(j); |
| 84 | } else { |
| 85 | cnt = Hash.Get_SHA_256((K_c + j).getBytes(StandardCharsets.UTF_8)); |
| 86 | map_cnt.put(j, cnt); |
| 87 | } |
| 88 | join_token[j - 1] = tool.Xor(tool.Xor(tool.Xor(w_0, w_i), join_hash), cnt); |