Make store_worker generic over chunk submission target

This commit is contained in:
Olivier 'reivilibre' 2021-11-20 11:23:17 +00:00
parent c73ac35df1
commit 202c7c57fd
1 changed files with 4 additions and 4 deletions

View File

@ -26,7 +26,7 @@ use crossbeam_channel::{Receiver, Sender};
use crossbeam_utils::thread; use crossbeam_utils::thread;
use log::{error, warn}; use log::{error, warn};
use crate::chunking::{RecursiveChunker, SENSIBLE_THRESHOLD}; use crate::chunking::{ChunkSubmissionTarget, RecursiveChunker, SENSIBLE_THRESHOLD};
use crate::commands; use crate::commands;
use crate::commands::{fully_integrate_pointer_node, retrieve_tree_node}; use crate::commands::{fully_integrate_pointer_node, retrieve_tree_node};
use crate::definitions::{PointerData, RecursiveChunkRef, RootTreeNode, TreeNode}; use crate::definitions::{PointerData, RecursiveChunkRef, RootTreeNode, TreeNode};
@ -83,9 +83,9 @@ pub fn store<RP: RawPile, PT: ProgressTracker>(
} }
} }
pub fn store_worker<RP: RawPile>( pub fn store_worker<CST: ChunkSubmissionTarget>(
root: &Path, root: &Path,
pile: &Pile<RP>, target: &CST,
paths: Receiver<String>, paths: Receiver<String>,
results: Sender<(String, Option<RecursiveChunkRef>)>, results: Sender<(String, Option<RecursiveChunkRef>)>,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
@ -93,7 +93,7 @@ pub fn store_worker<RP: RawPile>(
let full_path = root.join(&path); let full_path = root.join(&path);
match File::open(&full_path) { match File::open(&full_path) {
Ok(mut file) => { Ok(mut file) => {
let mut chunker = RecursiveChunker::new(SENSIBLE_THRESHOLD, pile); let mut chunker = RecursiveChunker::new(SENSIBLE_THRESHOLD, target);
// streaming copy from file to chunker, really cool :) // streaming copy from file to chunker, really cool :)
io::copy(&mut file, &mut chunker)?; io::copy(&mut file, &mut chunker)?;
let chunk_ref = chunker.finish()?; let chunk_ref = chunker.finish()?;