refactor: Inline run_split_plan in anticipation of combining more code
parent
91ac9627fa
commit
3235be572d
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
error::{DynError, ErrorKind, SimpleError},
|
error::{DynError, ErrorKind, SimpleError},
|
||||||
file_classification::{
|
file_classification::{
|
||||||
FileClassification, FileToSplit, FilesForProgress, FilesToSplitOrCompact,
|
FileClassification, FilesForProgress, FilesToSplitOrCompact,
|
||||||
},
|
},
|
||||||
partition_info::PartitionInfo,
|
partition_info::PartitionInfo,
|
||||||
PlanIR,
|
PlanIR,
|
||||||
|
@ -344,14 +344,24 @@ async fn run_plans(
|
||||||
FilesToSplitOrCompact::Split(files) => {
|
FilesToSplitOrCompact::Split(files) => {
|
||||||
let mut created_file_params =
|
let mut created_file_params =
|
||||||
Vec::with_capacity(files.iter().map(|f| f.split_times.len() + 1).sum());
|
Vec::with_capacity(files.iter().map(|f| f.split_times.len() + 1).sum());
|
||||||
for file in files {
|
for (file_to_split, file_inpad) in files.into_iter().zip(files_inpad.into_iter()) {
|
||||||
|
// target level of a split file is the same as its level
|
||||||
|
let target_level = file_to_split.file.compaction_level;
|
||||||
|
|
||||||
|
let plan_ir = components.ir_planner.split_plan(
|
||||||
|
file_inpad,
|
||||||
|
file_to_split.split_times.clone(),
|
||||||
|
Arc::clone(partition_info),
|
||||||
|
target_level,
|
||||||
|
);
|
||||||
|
|
||||||
created_file_params.extend(
|
created_file_params.extend(
|
||||||
run_split_plan(
|
execute_plan(
|
||||||
file,
|
plan_ir,
|
||||||
partition_info,
|
partition_info,
|
||||||
components,
|
components,
|
||||||
|
target_level,
|
||||||
Arc::clone(&job_semaphore),
|
Arc::clone(&job_semaphore),
|
||||||
scratchpad_ctx,
|
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
);
|
);
|
||||||
|
@ -362,42 +372,6 @@ async fn run_plans(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split a given file into multiple files
|
|
||||||
async fn run_split_plan(
|
|
||||||
file_to_split: &FileToSplit,
|
|
||||||
partition_info: &Arc<PartitionInfo>,
|
|
||||||
components: &Arc<Components>,
|
|
||||||
job_semaphore: Arc<InstrumentedAsyncSemaphore>,
|
|
||||||
scratchpad_ctx: &mut dyn Scratchpad,
|
|
||||||
) -> Result<Vec<ParquetFileParams>, DynError> {
|
|
||||||
// stage files
|
|
||||||
let input_path = (&file_to_split.file).into();
|
|
||||||
let input_uuids_inpad = scratchpad_ctx.load_to_scratchpad(&[input_path]).await;
|
|
||||||
let file_inpad = ParquetFile {
|
|
||||||
object_store_id: input_uuids_inpad[0],
|
|
||||||
..file_to_split.file.clone()
|
|
||||||
};
|
|
||||||
|
|
||||||
// target level of a split file is the same as its level
|
|
||||||
let target_level = file_to_split.file.compaction_level;
|
|
||||||
|
|
||||||
let plan_ir = components.ir_planner.split_plan(
|
|
||||||
file_inpad,
|
|
||||||
file_to_split.split_times.clone(),
|
|
||||||
Arc::clone(partition_info),
|
|
||||||
target_level,
|
|
||||||
);
|
|
||||||
|
|
||||||
execute_plan(
|
|
||||||
plan_ir,
|
|
||||||
partition_info,
|
|
||||||
components,
|
|
||||||
target_level,
|
|
||||||
job_semaphore,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute_plan(
|
async fn execute_plan(
|
||||||
plan_ir: PlanIR,
|
plan_ir: PlanIR,
|
||||||
partition_info: &Arc<PartitionInfo>,
|
partition_info: &Arc<PartitionInfo>,
|
||||||
|
|
Loading…
Reference in New Issue