Skip to content

Commit b0214ae

Browse files
author
Johanna
committed
resolved comments from PR and changed return type of MultiSketch::load
1 parent e051db4 commit b0214ae

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ pub fn main() -> Result<(), Error> {
418418
log::info!("Parsed {} samples in input list", input_files.len());
419419

420420
//check if any of the new files are already existant in the db
421-
let db_metadata: MultiSketch = MultiSketch::load(db)
422-
.expect(&format!("Could not read sketch metadata from .skm: {}", db));
421+
let db_metadata: MultiSketch = MultiSketch::load(db)?;
423422

424423
if !db_metadata.append_compatibility(&input_files) {
425424
panic!("Databases are not compatible for merging.")
@@ -472,15 +471,13 @@ pub fn main() -> Result<(), Error> {
472471
.open(format!("{}.skd", output))?;
473472
// stream sketch data directly to concat output file
474473
let mut db_sketch = File::open(format!("{}.skd", db))?;
475-
println!("{:?}", db_sketch);
476-
println!("{:?}", output_file);
477474
copy(&mut db_sketch, &mut output_file)?;
478475

479476
// merge and update skm from db1 and the new just sketched sketch
480477
let concat_metadata = db2_metadata.merge_sketches(&db_metadata);
481478
concat_metadata
482479
.save_metadata(output)
483-
.expect(&format!("Could not save metadata to {}", output));
480+
.unwrap_or_else(|_| panic!("Could not save metadata to {}", output));
484481
Ok(())
485482
}
486483

src/multisketch.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::panic;
2-
use std::error::Error;
2+
use anyhow::Error;
33
use std::fmt;
44
use std::fs::File;
55
use std::io::{BufReader, BufWriter};
@@ -60,7 +60,7 @@ impl MultiSketch {
6060
}
6161

6262
/// Saves the metadata
63-
pub fn save_metadata(&self, file_prefix: &str) -> Result<(), Box<dyn Error>> {
63+
pub fn save_metadata(&self, file_prefix: &str) -> Result<(), Error> {
6464
let filename = format!("{}.skm", file_prefix);
6565
log::info!("Saving sketch metadata to {filename}");
6666
let serial_file = BufWriter::new(File::create(filename)?);
@@ -69,7 +69,7 @@ impl MultiSketch {
6969
Ok(())
7070
}
7171

72-
pub fn load(file_prefix: &str) -> Result<Self, Box<dyn Error>> {
72+
pub fn load(file_prefix: &str) -> Result<Self, Error> {
7373
let filename = format!("{}.skm", file_prefix);
7474
log::info!("Loading sketch metadata from {filename}");
7575
let skm_file = BufReader::new(File::open(filename)?);

0 commit comments

Comments
 (0)