Created with IntelliJ IDEA. @Author: 杜凯 @Date: 2023/09/14/16:58 @Description: the server's process about the search algorithm of JXT
| 16 | * @Description: the server's process about the search algorithm of JXT |
| 17 | */ |
| 18 | public class Server_JXT { |
| 19 | private Map<BigInteger, ArrayList<tuple>> tset; |
| 20 | |
| 21 | private Bloom f_1; |
| 22 | private Bloom f_2; |
| 23 | |
| 24 | private BigInteger stag1; |
| 25 | private BigInteger stag2; |
| 26 | public Server_JXT(Map<BigInteger, ArrayList<tuple>> tset, Bloom f_1, Bloom f_2){ |
| 27 | this.tset = tset; |
| 28 | this.f_1 = f_1; |
| 29 | this.f_2 = f_2; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get the number of the first table's TSet entries |
| 34 | * @param stag1 the first table's stag |
| 35 | * @return the number of the matching TSet entries |
| 36 | */ |
| 37 | public int tset_table1_cnt(BigInteger stag1){ |
| 38 | this.stag1 = stag1; |
| 39 | return tset.get(stag1).size(); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get the number of the second table's TSet entries |
| 44 | * @param stag2 the second table's stag |
| 45 | * @return the number of the matching TSet entries |
| 46 | */ |
| 47 | public int tset_table2_cnt(BigInteger stag2){ |
| 48 | this.stag2 = stag2; |
| 49 | return tset.get(stag2).size(); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * the server operations of the search algorithm for JXT |
| 54 | * @param token1 joinToken(1) in JXT |
| 55 | * @param token2 joinToken(1) in JXT |
| 56 | * @param join_column the chosen column of the join attribute |
| 57 | * @return the matching result |
| 58 | */ |
| 59 | public ArrayList<byte[]> search(byte[][] token1, byte[][] token2, int join_column){ |
| 60 | ArrayList<byte[]> res = new ArrayList<>(); |
| 61 | |
| 62 | ArrayList<tuple> token1_tset = tset.get(stag1); |
| 63 | ArrayList<tuple> token2_tset = tset.get(stag2); |
| 64 | byte[][] xtoken1 = new byte[token1_tset.size()][]; |
| 65 | byte[][] xtoken2 = new byte[token2_tset.size()][]; |
| 66 | for (int i = 0; i < token1_tset.size(); i++) { |
| 67 | xtoken1[i] = tool.Xor(token1_tset.get(i).h_y[join_column], token1[i]); |
| 68 | } |
| 69 | for (int i = 0; i < token2_tset.size(); i++) { |
| 70 | xtoken2[i] = tool.Xor(token2_tset.get(i).h_x[join_column], token2[i]); |
| 71 | } |
| 72 | |
| 73 | for (int i = 0; i < token1_tset.size(); i++) { |
| 74 | for (int j = 0; j < token2_tset.size(); j++) { |
| 75 | long x = tool.bytesToLong(tool.Xor(xtoken1[i], xtoken2[j])); |
nothing calls this directly
no outgoing calls
no test coverage detected