refactor: Extract a conversion for convenience in tests
parent
dcab9d0ffc
commit
f5497a3a3d
|
@ -186,9 +186,7 @@ fn group_by_size(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
compact_one_partition, handler::CompactorConfig, parquet_file_filtering, ReadyToCompact,
|
||||
};
|
||||
use crate::{compact_one_partition, handler::CompactorConfig, parquet_file_filtering};
|
||||
use ::parquet_file::storage::ParquetStorage;
|
||||
use arrow_util::assert_batches_sorted_eq;
|
||||
use backoff::BackoffConfig;
|
||||
|
@ -408,19 +406,7 @@ mod tests {
|
|||
&compactor.parquet_file_candidate_bytes,
|
||||
);
|
||||
|
||||
let parquet_file_filtering::FilteredFiles {
|
||||
filter_result,
|
||||
partition,
|
||||
} = to_compact;
|
||||
|
||||
let files =
|
||||
if let parquet_file_filtering::FilterResult::Proceed { files, .. } = filter_result {
|
||||
files
|
||||
} else {
|
||||
panic!("Expected to get FilterResult::Proceed, got {filter_result:?}");
|
||||
};
|
||||
|
||||
let to_compact = ReadyToCompact { files, partition };
|
||||
let to_compact = to_compact.into();
|
||||
|
||||
compact_one_partition(&compactor, to_compact, "cold")
|
||||
.await
|
||||
|
@ -603,19 +589,7 @@ mod tests {
|
|||
&compactor.parquet_file_candidate_bytes,
|
||||
);
|
||||
|
||||
let parquet_file_filtering::FilteredFiles {
|
||||
filter_result,
|
||||
partition,
|
||||
} = to_compact;
|
||||
|
||||
let files =
|
||||
if let parquet_file_filtering::FilterResult::Proceed { files, .. } = filter_result {
|
||||
files
|
||||
} else {
|
||||
panic!("Expected to get FilterResult::Proceed, got {filter_result:?}");
|
||||
};
|
||||
|
||||
let to_compact = ReadyToCompact { files, partition };
|
||||
let to_compact = to_compact.into();
|
||||
|
||||
compact_one_partition(&compactor, to_compact, "cold")
|
||||
.await
|
||||
|
|
|
@ -77,7 +77,6 @@ mod tests {
|
|||
handler::CompactorConfig,
|
||||
parquet_file_filtering, parquet_file_lookup,
|
||||
tests::{test_setup, TestSetup},
|
||||
ReadyToCompact,
|
||||
};
|
||||
use arrow_util::assert_batches_sorted_eq;
|
||||
use backoff::BackoffConfig;
|
||||
|
@ -516,19 +515,7 @@ mod tests {
|
|||
&compactor.parquet_file_candidate_bytes,
|
||||
);
|
||||
|
||||
let parquet_file_filtering::FilteredFiles {
|
||||
filter_result,
|
||||
partition,
|
||||
} = to_compact;
|
||||
|
||||
let files =
|
||||
if let parquet_file_filtering::FilterResult::Proceed { files, .. } = filter_result {
|
||||
files
|
||||
} else {
|
||||
panic!("Expected to get FilterResult::Proceed, got {filter_result:?}");
|
||||
};
|
||||
|
||||
let to_compact = ReadyToCompact { files, partition };
|
||||
let to_compact = to_compact.into();
|
||||
|
||||
compact_one_partition(&compactor, to_compact, "hot")
|
||||
.await
|
||||
|
|
|
@ -334,6 +334,29 @@ pub mod tests {
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
// In tests that are verifying successful compaction not affected by the memory budget, this
|
||||
// converts a `parquet_file_filtering::FilteredFiles` that has a `filter_result` of
|
||||
// `parquet_file_filtering::FilterResult::Proceed` into a `ReadyToCompact` and panics if it
|
||||
// gets any other variant.
|
||||
impl From<parquet_file_filtering::FilteredFiles> for ReadyToCompact {
|
||||
fn from(filtered_files: parquet_file_filtering::FilteredFiles) -> Self {
|
||||
let parquet_file_filtering::FilteredFiles {
|
||||
filter_result,
|
||||
partition,
|
||||
} = filtered_files;
|
||||
|
||||
let files = if let parquet_file_filtering::FilterResult::Proceed { files, .. } =
|
||||
filter_result
|
||||
{
|
||||
files
|
||||
} else {
|
||||
panic!("Expected to get FilterResult::Proceed, got {filter_result:?}");
|
||||
};
|
||||
|
||||
Self { files, partition }
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn empty_candidates_compacts_nothing() {
|
||||
test_helpers::maybe_start_logging();
|
||||
|
|
Loading…
Reference in New Issue