Computes the inner join of given sets.
(join_input: &JoinInput)
| 244 | |
| 245 | // Computes the inner join of given sets. |
| 246 | fn get_inner_join_columns(join_input: &JoinInput) -> Result<ColumnsMap> { |
| 247 | let mut result_columns = ColumnsMap::init_result_columns(join_input)?; |
| 248 | |
| 249 | // Check row by row that the content of the key columns of the first set intersects with the second set |
| 250 | for row_ind0 in 0..join_input.number_of_rows_set_0() { |
| 251 | // If the null column entry is zero or there are empty entries, just insert a zero row |
| 252 | if join_input.row_has_empty_entries(row_ind0) { |
| 253 | result_columns.append_zero_row(); |
| 254 | continue; |
| 255 | } |
| 256 | // Merge the key columns of the first set |
| 257 | let row_key = join_input |
| 258 | .set0 |
| 259 | .get_flattened_row(row_ind0, &join_input.key_headers0); |
| 260 | // Check that the row key of the first set is contained in the second set |
| 261 | if join_input.key_data_hashmap1.contains_key(&row_key) { |
| 262 | // Add the columns of the first set first |
| 263 | for (header0, _) in join_input.headers_types0 { |
| 264 | result_columns.copy_entry_from_column(header0, header0, &join_input.set0, row_ind0); |
| 265 | } |
| 266 | // Extract the corresponding row of the second set |
| 267 | let row_ind1 = join_input.key_data_hashmap1[&row_key]; |
| 268 | for header1 in &join_input.nonkey_headers1 { |
| 269 | result_columns.copy_entry_from_column(header1, header1, &join_input.set1, row_ind1); |
| 270 | } |
| 271 | } else { |
| 272 | result_columns.append_zero_row(); |
| 273 | } |
| 274 | } |
| 275 | Ok(result_columns) |
| 276 | } |
| 277 | |
| 278 | // Preprocessed input of join algorithms. |
| 279 | // Note that it contains a hashmap of the rows of the second set hashed by their key columns, which simplifies computation of the set intersection |
no test coverage detected