Skip to content

Commit

Permalink
Revert to Btree
Browse files Browse the repository at this point in the history
  • Loading branch information
kimono-koans committed Jan 5, 2024
1 parent be471d6 commit c2c19d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lookup/file_mounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::data::paths::PathDeconstruction;
use crate::library::results::{HttmError, HttmResult};
use crate::lookup::versions::ProximateDatasetAndOptAlts;
use crate::GLOBAL_CONFIG;
use hashbrown::HashSet;
use rayon::prelude::*;
use std::collections::BTreeSet;
use std::ops::Deref;
use std::path::PathBuf;

Expand Down Expand Up @@ -50,12 +50,12 @@ impl MountDisplay {

#[derive(Debug)]
pub struct MountsForFiles<'a> {
inner: HashSet<ProximateDatasetAndOptAlts<'a>>,
inner: BTreeSet<ProximateDatasetAndOptAlts<'a>>,
mount_display: &'a MountDisplay,
}

impl<'a> Deref for MountsForFiles<'a> {
type Target = HashSet<ProximateDatasetAndOptAlts<'a>>;
type Target = BTreeSet<ProximateDatasetAndOptAlts<'a>>;

fn deref(&self) -> &Self::Target {
&self.inner
Expand All @@ -70,7 +70,7 @@ impl<'a> MountsForFiles<'a> {
pub fn new(mount_display: &'a MountDisplay) -> HttmResult<Self> {
// we only check for phantom files in "mount for file" mode because
// people should be able to search for deleted files in other modes
let set: HashSet<ProximateDatasetAndOptAlts> = GLOBAL_CONFIG
let set: BTreeSet<ProximateDatasetAndOptAlts> = GLOBAL_CONFIG
.paths
.par_iter()
.filter_map(|pd| match ProximateDatasetAndOptAlts::new(pd) {
Expand Down
14 changes: 14 additions & 0 deletions src/lookup/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ pub struct ProximateDatasetAndOptAlts<'a> {
pub opt_alts: Option<&'a Vec<PathBuf>>,
}

impl<'a> Ord for ProximateDatasetAndOptAlts<'a> {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.pathdata.cmp(&other.pathdata)
}
}

impl<'a> PartialOrd for ProximateDatasetAndOptAlts<'a> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl<'a> ProximateDatasetAndOptAlts<'a> {
pub fn new(pathdata: &'a PathData) -> HttmResult<Self> {
// here, we take our file path and get back possibly multiple ZFS dataset mountpoints
Expand Down

0 comments on commit c2c19d3

Please sign in to comment.