diff --git a/src/backends/ntriples.rs b/src/backends/ntriples.rs index 0711aaa..9b33b4d 100644 --- a/src/backends/ntriples.rs +++ b/src/backends/ntriples.rs @@ -64,47 +64,59 @@ impl Backend for NTriples { Err(_) => return Err(format!("Error retrieving the {}th row", i)), }; - if let Err(_) = formatter.format(&Triple { - subject: match row.get(0) { - Some(subject) => match subject { - AnyValue::Utf8(iri) => NamedNode { - iri: &iri[1..iri.len() - 1], + if formatter + .format(&Triple { + subject: match row.get(0) { + Some(subject) => match subject { + AnyValue::Utf8(iri) => NamedNode { + iri: &iri[1..iri.len() - 1], + } + .into(), + _ => { + return Err(format!("Cannot parse from non-string at {}th row", i)) + } + }, + None => { + return Err(format!("Error obtaining the subject of the {}th row", i)) } - .into(), - _ => return Err(format!("Cannot parse from non-string at {}th row", i)), }, - None => return Err(format!("Error obtaining the subject of the {}th row", i)), - }, - predicate: match row.get(1) { - Some(predicate) => match predicate { - AnyValue::Utf8(iri) => NamedNode { - iri: &iri[1..iri.len() - 1], + predicate: match row.get(1) { + Some(predicate) => match predicate { + AnyValue::Utf8(iri) => NamedNode { + iri: &iri[1..iri.len() - 1], + }, + _ => { + return Err(format!("Cannot parse from non-string at {}th row", i)) + } + }, + None => { + return Err(format!("Error obtaining the predicate of the {}th row", i)) } - .into(), - _ => return Err(format!("Cannot parse from non-string at {}th row", i)), }, - None => { - return Err(format!("Error obtaining the predicate of the {}th row", i)) - } - }, - object: match row.get(2) { - Some(object) => match object { - AnyValue::Utf8(iri) => NamedNode { - iri: &iri[1..iri.len() - 1], + object: match row.get(2) { + Some(object) => match object { + AnyValue::Utf8(iri) => NamedNode { + iri: &iri[1..iri.len() - 1], + } + .into(), + _ => { + return Err(format!("Cannot parse from non-string at {}th row", i)) + } + }, + None => { + return Err(format!("Error obtaining the object of the {}th row", i)) } - .into(), - _ => return Err(format!("Cannot parse from non-string at {}th row", i)), }, - None => return Err(format!("Error obtaining the object of the {}th row", i)), - }, - }) { + }) + .is_err() + { return Err(format!("Error parsing the {}th row", i)); } } match formatter.finish() { Ok(_) => Ok(()), - Err(_) => return Err(format!("Error storing the results to the file")), + Err(_) => Err(String::from("Error storing the results to the file")), } } } diff --git a/src/backends/parquet.rs b/src/backends/parquet.rs index f4ca51c..6ccb2da 100644 --- a/src/backends/parquet.rs +++ b/src/backends/parquet.rs @@ -12,13 +12,13 @@ impl Backend for Parquet { todo!() } - fn export(path: &str, mut df: &mut DataFrame) -> Result<(), String> { + fn export(path: &str, df: &mut DataFrame) -> Result<(), String> { let buffer = match File::create(path) { Ok(buffer) => buffer, Err(_) => return Err(String::from("Error creating the Parquet file")), }; - match ParquetWriter::new(buffer).finish(&mut df) { + match ParquetWriter::new(buffer).finish(df) { Ok(_) => Ok(()), Err(_) => Err(String::from("Error writing to the Parquet file")), } diff --git a/src/pschema.rs b/src/pschema.rs index 6db667b..fd0019a 100644 --- a/src/pschema.rs +++ b/src/pschema.rs @@ -105,7 +105,7 @@ impl PSchema { .gt(lit(0)), ) .left_join( - graph.to_owned().edges.lazy(), + graph.edges.lazy(), Column::VertexId.as_ref(), Column::Subject.as_ref(), )