MCPcopy Create free account
hub / github.com/CDSecLab/MJXT / Server_JXTp

Class Server_JXTp

src/main/java/server/Server_JXTp.java:17–64  ·  view source on GitHub ↗

Created with IntelliJ IDEA. @Author: 杜凯 @Date: 2023/09/22/20:40 @Description: the server's process about the search algorithm of JXT+

Source from the content-addressed store, hash-verified

15 * @Description: the server's process about the search algorithm of JXT+
16 */
17public class Server_JXTp {
18 private Map<BigInteger, ArrayList<byte[]>> tset;
19 private Bloom f_1;
20 private Bloom f_2;
21 private Map<Long, ArrayList<byte[]>> cset1;
22 private Map<Long, ArrayList<byte[]>> cset2;
23 private BigInteger stag1;
24 public Server_JXTp(Map<BigInteger, ArrayList<byte[]>> tset, Bloom f_1, Map<Long, ArrayList<byte[]>> cset1,
25 Bloom f_2, Map<Long, ArrayList<byte[]>> cset2){
26 this.tset = tset;
27 this.f_1 = f_1;
28 this.cset1 = cset1;
29 this.f_2 = f_2;
30 this.cset2 = cset2;
31 }
32
33 /**
34 * Get the number of the first table's TSet entries
35 * @param stag1 the first table's stag
36 * @return the number of the matching TSet entries
37 */
38 public int tset_table1_cnt(BigInteger stag1){
39 this.stag1 = stag1;
40 return tset.get(stag1).size();
41 }
42
43 /**
44 * the server operations of the search algorithm for JXT+
45 * @param stoken sjointoken in JXT+
46 * @param xtoken xjointoken in JXT+
47 * @return the matching results
48 */
49 public ArrayList<ArrayList<byte[]>> search(byte[][] stoken, byte[][] xtoken){
50 ArrayList<ArrayList<byte[]>> res = new ArrayList<>();
51
52 ArrayList<byte[]> token1_tset = tset.get(stag1);
53 for (int i = 0; i < token1_tset.size(); i++) {
54 byte[] xtoken_t = tool.Xor(xtoken[i], token1_tset.get(i));
55 long xtoken_long = tool.bytesToLong(xtoken_t);
56 if (f_2.mayContain(xtoken_long)){
57 byte[] stoken_t = tool.Xor(stoken[i], token1_tset.get(i));
58 res.add(cset1.get(tool.bytesToLong(stoken_t)));
59 res.add(cset2.get(xtoken_long));
60 }
61 }
62 return res;
63 }
64}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected