in deduplication/src/file_deduplication.rs [343:372]
fn dedup_query_against_local_data(
&mut self,
chunks: &[MerkleHash],
) -> Option<(usize, FileDataSequenceEntry, bool)> {
// It's important for the defrag prevention to have a good estimate of the number of chunks in
// a row that can be deduplicated, so this pulls through the
if let Some(&base_idx) = self.new_data_hash_lookup.get(&chunks[0]) {
let mut n_bytes = self.new_data[base_idx].data.len();
let mut end_idx = base_idx + 1;
for (i, chunk) in chunks.iter().enumerate().skip(1) {
if let Some(&idx) = self.new_data_hash_lookup.get(chunk) {
if idx == base_idx + i {
end_idx = idx + 1;
n_bytes += self.new_data[idx].data.len();
continue;
}
}
break;
}
Some((
end_idx - base_idx,
FileDataSequenceEntry::new(MerkleHash::marker(), n_bytes, base_idx, end_idx),
false,
))
} else {
None
}
}