From bd4c411f76a8d57cd59e5daa958561760a0b5658 Mon Sep 17 00:00:00 2001 From: yajc Date: Mon, 9 May 2022 15:05:23 -0700 Subject: [PATCH] Remove unused load_json fucntion --- protocol/src/fileio.rs | 37 ------------------------------ protocol/src/private_id/company.rs | 13 +---------- protocol/src/private_id/partner.rs | 7 +----- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/protocol/src/fileio.rs b/protocol/src/fileio.rs index fc8050a..6087cde 100644 --- a/protocol/src/fileio.rs +++ b/protocol/src/fileio.rs @@ -140,43 +140,6 @@ pub fn load_data(data: Arc>, path: &str, has_headers: bool) { } } -pub fn load_json(data: Arc>, json_table: &str, has_headers: bool) -> bool { - // Read json object from dynamic str into the expected Vec form (previously from a CSV) - let table: Value = serde_json::from_str(json_table).unwrap(); - let table: &Vec = table.as_array().unwrap(); - let table_len = table.len(); - - let mut lines: Vec> = vec![vec!["".to_string()]; table.len()]; // -OR- files::read_csv_as_strings(path) - for (row_num, row) in table.iter().enumerate() { - lines[row_num] = vec![row.as_str().unwrap().to_string()]; - } - - let mut ret = false; - if let Ok(mut wguard) = data.write() { - if wguard.records.is_empty() { - let mut line_it = lines.drain(..); - if has_headers { - if let Some(headers) = line_it.next() { - wguard.headers = headers; - } - } - for line in line_it { - if let Some((key, rest)) = line.split_first() { - wguard.records.insert(key.to_string(), rest.to_vec()); - } - } - let keys_len = wguard.records.len(); - info!( - "Read {} lines from json (dedup: {} lines)", - table_len, - table_len - keys_len - ); - ret = true - } - } - ret -} - #[cfg(test)] mod tests { use super::*; diff --git a/protocol/src/private_id/company.rs b/protocol/src/private_id/company.rs index e342ebb..c9ac472 100644 --- a/protocol/src/private_id/company.rs +++ b/protocol/src/private_id/company.rs @@ -21,7 +21,7 @@ use common::{ }; use crate::{ - fileio::{load_data, load_json, KeyedCSV}, + fileio::{load_data, KeyedCSV}, private_id::traits::CompanyPrivateIdProtocol, }; @@ -69,17 +69,6 @@ impl CompanyPrivateId { ); } - pub fn load_json(&self, path: &str, input_with_headers: bool) -> bool { - let status = load_json(self.plain_data.clone(), path, input_with_headers); - if status { - fill_permute( - self.permutation.clone(), - (*self.plain_data.clone().read().unwrap()).records.len(), - ); - } - status - } - pub fn get_e_company_size(&self) -> usize { self.e_company.read().unwrap().len() } diff --git a/protocol/src/private_id/partner.rs b/protocol/src/private_id/partner.rs index 9b2f550..43e9c95 100644 --- a/protocol/src/private_id/partner.rs +++ b/protocol/src/private_id/partner.rs @@ -13,7 +13,7 @@ use crypto::{ }; use crate::{ - fileio::{load_data, load_json, KeyedCSV}, + fileio::{load_data, KeyedCSV}, private_id::traits::PartnerPrivateIdProtocol, }; @@ -51,11 +51,6 @@ impl PartnerPrivateId { Ok(()) } - pub fn load_json(&self, path: &str, input_with_headers: bool) -> Result<(), ProtocolError> { - load_json(self.plain_data.clone(), path, input_with_headers); - Ok(()) - } - pub fn get_size(&self) -> usize { self.plain_data.clone().read().unwrap().records.len() }