diff --git a/crates/datashed/src/commands/index/mod.rs b/crates/datashed/src/commands/index/mod.rs index 3423adc..3f7b1f1 100644 --- a/crates/datashed/src/commands/index/mod.rs +++ b/crates/datashed/src/commands/index/mod.rs @@ -67,6 +67,7 @@ pub(crate) struct Index { #[derive(Debug, Default)] struct Row { path: PathBuf, + hash: String, ppn: String, kind: DocumentKind, msc: Option, @@ -80,7 +81,6 @@ struct Row { size: u64, strlen: u64, mtime: u64, - hash: String, } impl TryFrom<&PathBuf> for Row { @@ -97,6 +97,7 @@ impl TryFrom<&PathBuf> for Row { Ok(Row { path: path.into(), + hash: doc.hash(), ppn: doc.ppn(), kind: doc.kind(), lfreq: doc.lfreq(), @@ -107,7 +108,6 @@ impl TryFrom<&PathBuf> for Row { size: doc.size(), strlen: doc.strlen(), mtime: doc.modified(), - hash: doc.hash(), lang_code, lang_score, ..Default::default() @@ -192,6 +192,7 @@ impl Index { let mut remote: Vec<&str> = vec![]; let mut path: Vec = vec![]; + let mut hash: Vec = vec![]; let mut ppn: Vec = vec![]; let mut kind: Vec = vec![]; let mut msc: Vec> = vec![]; @@ -205,11 +206,10 @@ impl Index { let mut size: Vec = vec![]; let mut strlen: Vec = vec![]; let mut mtime: Vec = vec![]; - let mut hash: Vec = vec![]; for row in rows.into_iter() { - let hash_ = row.hash[0..8].to_string(); let path_ = relpath(&row.path, base_dir); + let hash_ = row.hash[0..8].to_string(); let kind_ = refinements .remove(&(path_.clone(), hash_.clone())) .or(kind_map @@ -217,6 +217,7 @@ impl Index { .unwrap_or(row.kind); remote.push(&config.metadata.name); + hash.push(hash_); path.push(path_); kind.push(kind_.to_string()); msc.push(msc_map.get(&row.ppn).cloned()); @@ -230,13 +231,13 @@ impl Index { size.push(row.size); strlen.push(row.strlen); mtime.push(row.mtime); - hash.push(hash_); ppn.push(row.ppn); } let df = DataFrame::new(vec![ Column::new("remote".into(), remote), Column::new("path".into(), path), + Column::new("hash".into(), hash), Column::new("ppn".into(), ppn), Column::new("kind".into(), kind), Column::new("msc".into(), msc), @@ -250,7 +251,6 @@ impl Index { Column::new("size".into(), size), Column::new("strlen".into(), strlen), Column::new("mtime".into(), mtime), - Column::new("hash".into(), hash), ])?; let mut df: DataFrame =