()
| 60 | } |
| 61 | |
| 62 | public void construct() { |
| 63 | //Step 1 read the dataset from the tables |
| 64 | //Step 1.1 prepare the parameters |
| 65 | l_max = new int[join_column]; |
| 66 | id = new String[record_num + 1]; |
| 67 | keyword = new String[record_num + 1][key_column]; |
| 68 | join_attr = new String[record_num + 1][join_column]; |
| 69 | Map<String, ArrayList<Integer>> reverse_id = new LinkedHashMap<>(); |
| 70 | Map<String, Integer> l_max_cnt = new HashMap<>(); |
| 71 | String path = "data/table" + table_id + "/table" + table_id + "_k" + key_column |
| 72 | + "_j" + join_column + "_" + record_num + condition + ".csv"; |
| 73 | //Step 1.2 begin to read dataset and statistics the l_max |
| 74 | try (Reader reader = Files.newBufferedReader(Paths.get(path))) { |
| 75 | Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(reader); |
| 76 | int counter = 0; |
| 77 | for (CSVRecord record : records) { |
| 78 | id[counter] = record.get(0); |
| 79 | for (int j = 0; j < key_column; j++) { |
| 80 | keyword[counter][j] = record.get(j + 1); |
| 81 | if (counter != 0) { |
| 82 | String kword = keyword[0][j] + record.get(j + 1);//attribute-value pair |
| 83 | if (!reverse_id.containsKey(kword)) |
| 84 | reverse_id.put(kword, new ArrayList<>()); |
| 85 | reverse_id.get(kword).add(counter); |
| 86 | for (int i = 0; i < join_column; i++) { |
| 87 | String key = kword + record.get(key_column + i + 1); |
| 88 | int cnt; |
| 89 | if (l_max_cnt.containsKey(key)) { |
| 90 | cnt = l_max_cnt.get(key) + 1; |
| 91 | l_max_cnt.put(key, cnt); |
| 92 | } else { |
| 93 | l_max_cnt.put(key, 1); |
| 94 | cnt = 1; |
| 95 | } |
| 96 | l_max[i] = Math.max(l_max[i], cnt); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | //also join-attribute values pairs are also seen as the attribute-value pair |
| 101 | for (int j = 0; j < join_column; j++) { |
| 102 | join_attr[counter][j] = record.get(key_column + j + 1); |
| 103 | if (counter != 0) { |
| 104 | String kword = join_attr[0][j] + record.get(key_column + j + 1); |
| 105 | if (!reverse_id.containsKey(kword)) |
| 106 | reverse_id.put(kword, new ArrayList<>()); |
| 107 | reverse_id.get(kword).add(counter); |
| 108 | for (int i = 0; i < join_column; i++) { |
| 109 | String key = kword + record.get(key_column + i + 1); |
| 110 | int cnt; |
| 111 | if (l_max_cnt.containsKey(key)) { |
| 112 | cnt = l_max_cnt.get(key) + 1; |
| 113 | l_max_cnt.put(key, cnt); |
| 114 | } else { |
| 115 | l_max_cnt.put(key, 1); |
| 116 | cnt = 1; |
| 117 | } |
| 118 | l_max[i] = Math.max(l_max[i], cnt); |
| 119 | } |
nothing calls this directly
no test coverage detected