MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / get_left_join_columns

Function get_left_join_columns

ciphercore-base/src/evaluators/join.rs:314–356  ·  view source on GitHub ↗

Computes the left join of given sets. These sets and necessary precomputations should be contained in the join input.

(join_input: &JoinInput)

Source from the content-addressed store, hash-verified

312// Computes the left join of given sets.
313// These sets and necessary precomputations should be contained in the join input.
314fn get_left_join_columns(join_input: &JoinInput) -> Result<ColumnsMap> {
315 let mut result_columns = ColumnsMap::init_result_columns(join_input)?;
316
317 // Check row by row that the content of the key columns of the first set intersects with the second one.
318 // If yes, append the row of the first set with the columns of the second one.
319 // If no, append it with zeros.
320 for row_ind0 in 0..join_input.number_of_rows_set_0() {
321 // If the null column entry is zero, just insert a zero row
322 if join_input.set0.null_column[row_ind0] == 0 {
323 result_columns.append_zero_row();
324 continue;
325 }
326 // Add the columns of the first set first
327 for (header0, _) in join_input.headers_types0.iter() {
328 result_columns.copy_entry_from_column(header0, header0, &join_input.set0, row_ind0);
329 }
330 // If there are empty entries in the key columns, append the current row with zeros
331 if join_input.row_has_empty_entries(row_ind0) {
332 for header1 in &join_input.nonkey_headers1 {
333 result_columns.append_zero_entry(header1);
334 }
335 continue;
336 }
337 // Merge the key columns of the first set
338 let row_key = join_input
339 .set0
340 .get_flattened_row(row_ind0, &join_input.key_headers0);
341 // Check that the row key of the first set is contained in the second set
342 if join_input.key_data_hashmap1.contains_key(&row_key) {
343 // Extract the corresponding row of the second set and attach to the row of the first set
344 let row_ind1 = join_input.key_data_hashmap1[&row_key];
345 for header1 in &join_input.nonkey_headers1 {
346 result_columns.copy_entry_from_column(header1, header1, &join_input.set1, row_ind1);
347 }
348 } else {
349 // Append the current row with zeros
350 for header1 in &join_input.nonkey_headers1 {
351 result_columns.append_zero_entry(header1);
352 }
353 }
354 }
355 Ok(result_columns)
356}
357
358// Computes the union join of given sets.
359// These sets and necessary precomputations should be contained in the join input.

Callers 1

evaluate_joinFunction · 0.85

Calls 6

number_of_rows_set_0Method · 0.80
append_zero_rowMethod · 0.80
row_has_empty_entriesMethod · 0.80
append_zero_entryMethod · 0.80
get_flattened_rowMethod · 0.80

Tested by

no test coverage detected