Created with IntelliJ IDEA. @Author: 杜凯 @Date: 2024/03/20/9:24 @Description: the server's process about the search algorithm of JXT called MJXT, where MJXT is a Join-query scheme supporting the multi-tables (three or more) search by a trivial method which leak SRP(sub-query pattern).
| 19 | * supporting the multi-tables (three or more) search by a trivial method which leak SRP(sub-query pattern). |
| 20 | */ |
| 21 | public class Server_MJXT { |
| 22 | private Map<BigInteger, ArrayList<tuple>> tset; |
| 23 | private Bloom[] f; |
| 24 | private BigInteger[] stag; |
| 25 | private int table_num; |
| 26 | |
| 27 | public Server_MJXT(Map<BigInteger, ArrayList<tuple>> tset, Setup_JXT[] table){ |
| 28 | this.tset = tset; |
| 29 | table_num = table.length; |
| 30 | f = new Bloom[table_num]; |
| 31 | for (int i = 0; i < table_num; i++) { |
| 32 | f[i] = table[i].getF(); |
| 33 | } |
| 34 | } |
| 35 | /** |
| 36 | * Get the number of the both table's TSet entries |
| 37 | * @param stag the both table's stag |
| 38 | * @return the numbers of the matching TSet entries |
| 39 | */ |
| 40 | public int[] tset_table_cnt(BigInteger[] stag){ |
| 41 | this.stag = stag; |
| 42 | int[] cnt = new int[table_num]; |
| 43 | for (int i = 0; i < table_num; i++) { |
| 44 | cnt[i] = tset.get(stag[i]).size(); |
| 45 | } |
| 46 | return cnt; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * the server operations of the search algorithm for MJXT |
| 51 | * @param join_tokens1 joinToken(1) in JXT |
| 52 | * @param join_tokens2 joinToken(1) in JXT |
| 53 | * @param join_column the chosen column of the join attribute |
| 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++) { |
nothing calls this directly
no outgoing calls
no test coverage detected