Created with IntelliJ IDEA. @Author: KaiDu @Date: 2023/09/22/16:37 @Description: the setup algorithm of JXT+
| 21 | * @Description: the setup algorithm of JXT+ |
| 22 | */ |
| 23 | public class Setup_JXTp { |
| 24 | private static String K_aes = "8975924566f6e252"; |
| 25 | private static String K_token = "89b7a92966f6eb32"; |
| 26 | private static String K_w = "7975922666f6eb02"; |
| 27 | private static String K_z = "9862192ad6f6ef65"; |
| 28 | private static String K_h = "9874a22554e7db85"; |
| 29 | private int table_id; |
| 30 | private int key_column; |
| 31 | private int join_column; |
| 32 | private int record_num; |
| 33 | private String condition; |
| 34 | private String[] id; |
| 35 | private String[][] keyword; |
| 36 | private String[][] join_attr; |
| 37 | private Bloom f;//the XSet is implemented by the Bloom filter |
| 38 | private Map<BigInteger, ArrayList<byte[]>> tset = new LinkedHashMap<>(); |
| 39 | private Map<Long, ArrayList<byte[]>> cset = new HashMap<>();//the CSet for JXT+ is implemented by the map |
| 40 | /** |
| 41 | * |
| 42 | * @param table_id_ the table index |
| 43 | * @param key_column_num the number of columns which are not join attribute |
| 44 | * @param join_column_num the number of column |
| 45 | * @param record the number of records of the table |
| 46 | */ |
| 47 | public Setup_JXTp(int table_id_, int key_column_num, int join_column_num, int record, String condition_t){ |
| 48 | table_id = table_id_; |
| 49 | key_column = key_column_num; |
| 50 | join_column = join_column_num; |
| 51 | record_num = record; |
| 52 | condition = condition_t; |
| 53 | } |
| 54 | |
| 55 | public void construct() { |
| 56 | //Step 1 read the dataset from the tables |
| 57 | //Step 1.1 prepare the parameters |
| 58 | id = new String[record_num + 1]; |
| 59 | keyword = new String[record_num + 1][key_column]; |
| 60 | join_attr = new String[record_num + 1][join_column]; |
| 61 | Map<String, ArrayList<Integer>> reverse_id = new LinkedHashMap<>();//the pairs of (attribute-value pair, record ids) |
| 62 | String path = "data/table" + table_id + "/table" + table_id + "_k" + key_column |
| 63 | + "_j" + join_column + "_" + record_num + condition +".csv"; |
| 64 | //Step 1.2 begin to read dataset |
| 65 | try (Reader reader = Files.newBufferedReader(Paths.get(path))) { |
| 66 | Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(reader); |
| 67 | int counter = 0; |
| 68 | for (CSVRecord record : records) { |
| 69 | id[counter] = record.get(0); |
| 70 | for (int j = 0; j < key_column; j++) { |
| 71 | keyword[counter][j] = record.get(j + 1); |
| 72 | if (counter != 0) { |
| 73 | String kword = keyword[0][j] + record.get(j + 1);//attribute-value pair |
| 74 | if (!reverse_id.containsKey(kword)) |
| 75 | reverse_id.put(kword, new ArrayList<>()); |
| 76 | reverse_id.get(kword).add(counter); |
| 77 | } |
| 78 | } |
| 79 | //also join-attribute values pairs are also seen as the attribute-value pair |
| 80 | for (int j = 0; j < join_column; j++) { |
nothing calls this directly
no outgoing calls
no test coverage detected