Attach a given shared column to shares of columns
(&mut self, header: &str, column: Node)
| 503 | |
| 504 | // Attach a given shared column to shares of columns |
| 505 | fn attach_column(&mut self, header: &str, column: Node) -> Result<()> { |
| 506 | match self { |
| 507 | Columns::Public(columns) => { |
| 508 | if is_shared(&column)? { |
| 509 | return Err(runtime_error!("New columns should be public")); |
| 510 | } |
| 511 | columns.push((header.to_owned(), column)); |
| 512 | } |
| 513 | Columns::Shared(shares) => { |
| 514 | if is_shared(&column)? { |
| 515 | for (share_id, share) in shares.iter_mut().enumerate() { |
| 516 | share.push((header.to_owned(), column.tuple_get(share_id as u64)?)); |
| 517 | } |
| 518 | } else { |
| 519 | // If column is public, fake its sharing as (column, 0, 0). |
| 520 | let zero_share = zeros_like(column.clone())?; |
| 521 | for (share_id, share) in shares.iter_mut().enumerate() { |
| 522 | if share_id == 0 { |
| 523 | share.push((header.to_owned(), column.clone())); |
| 524 | } else { |
| 525 | share.push((header.to_owned(), zero_share.clone())); |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | Ok(()) |
| 533 | } |
| 534 | |
| 535 | fn extract_and_attach(&mut self, header: &str, columns_shares: &DataShares) -> Result<()> { |
| 536 | if columns_shares.column_has_mask(header) { |
no test coverage detected