Skip to content

Commit

Permalink
simplify and encapsulate
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Aug 27, 2024
1 parent 6fee403 commit 0675402
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/core/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::ops::{Deref, DerefMut};

use camino::Utf8Path as Path;
use camino::Utf8PathBuf as PathBuf;
use std::collections::HashSet;

use crate::encodings::Idx;
use crate::manifest::{Manifest, Record};
Expand Down Expand Up @@ -217,8 +216,8 @@ impl Collection {
Ok(sig)
}

pub fn select_picklist(&self, pick: &HashSet<(String, String)>) -> Self {
let manifest = self.manifest.select_picklist(pick);
pub fn intersect_manifest(&self, mf: &Manifest) -> Self {
let manifest = self.manifest.intersect_manifest(mf);
Self { manifest, storage: self.storage.clone() }

Check warning on line 221 in src/core/src/collection.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/collection.rs#L219-L221

Added lines #L219 - L221 were not covered by tests
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/core/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,18 @@ impl Manifest {
self.records.iter()
}

pub fn select_picklist(&self, pick: &HashSet<(String, String)>) -> Self {
pub fn intersect_manifest(&self, other: &Manifest) -> Self {

Check warning on line 214 in src/core/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/manifest.rs#L214

Added line #L214 was not covered by tests
// @CTB: do we want to key on other things, like ksize, moltype, hash?
// As long as we avoid internal_location we should be fine...

// extract tuples from other mf:
let pairs: HashSet<_> = other
.iter()
.map(|r| (r.name(), r.md5()))

Check warning on line 221 in src/core/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/manifest.rs#L221

Added line #L221 was not covered by tests
.collect();

let records = self.records.iter().filter(|row| {
pick.contains(&(row.name().clone(), row.md5().clone()))
pairs.contains(&(row.name(), row.md5()))

Check warning on line 225 in src/core/src/manifest.rs

View check run for this annotation

Codecov / codecov/patch

src/core/src/manifest.rs#L225

Added line #L225 was not covered by tests
}).cloned().collect();

Self { records }
Expand Down

0 comments on commit 0675402

Please sign in to comment.