mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-08-12 09:19:44 +00:00
feat: manual compaction parallelism (#7086)
* feat/manual-compaction-parallelism: ### Add Parallelism Support to Compaction Requests - **`Cargo.lock` & `Cargo.toml`**: Updated `greptime-proto` dependency to a new revision. - **`flush_compact_table.rs`**: Enhanced `parse_compact_params` to support a new `parallelism` parameter, allowing users to specify the level of parallelism for table compaction. - **`handle_compaction.rs`**: Integrated `parallelism` into the compaction scheduling process, defaulting to 1 if not specified. - **`request.rs` & `region_request.rs`**: Modified `CompactRequest` to include `parallelism`, with logic to handle unspecifie values. - **`requests.rs`**: Updated `CompactTableRequest` structure to include an optional `parallelism` field. Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * feat/manual-compaction-parallelism: ### Commit Message Enhance Compaction Request Handling - **`flush_compact_table.rs`**: - Renamed `parse_compact_params` to `parse_compact_request`. - Introduced `DEFAULT_COMPACTION_PARALLELISM` constant. - Updated parsing logic to handle keyword arguments for `strict_window` and `regular` compaction types, including `parallelism` and `window`. - Modified tests to reflect changes in parsing logic and default parallelism handling. - **`request.rs`**: - Updated `parallelism` handling in `RegionRequestBody::Compact` to use the new default value. - **`requests.rs`**: - Changed `CompactTableRequest` to use a non-optional `parallelism` field with a default value of 1. Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * feat/manual-compaction-parallelism: ### Update `flush_compact_table.rs` Parameter Validation - Modified parameter validation in `flush_compact_table.rs` to restrict the maximum number of parameters from 4 to 3 in the `parse_compact_request` function. Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> * feat/manual-compaction-parallelism: Update `greptime-proto` dependency - Updated the `greptime-proto` dependency to a new revision in both `Cargo.lock` and `Cargo.toml`. Signed-off-by: Lei, HUANG <mrsatangel@gmail.com> --------- Signed-off-by: Lei, HUANG <mrsatangel@gmail.com>
This commit is contained in:
@@ -338,9 +338,18 @@ fn make_region_compact(compact: CompactRequest) -> Result<Vec<(RegionId, RegionR
|
||||
let options = compact
|
||||
.options
|
||||
.unwrap_or(compact_request::Options::Regular(Default::default()));
|
||||
// Convert parallelism: a value of 0 indicates no specific parallelism requested (None)
|
||||
let parallelism = if compact.parallelism == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(compact.parallelism)
|
||||
};
|
||||
Ok(vec![(
|
||||
region_id,
|
||||
RegionRequest::Compact(RegionCompactRequest { options }),
|
||||
RegionRequest::Compact(RegionCompactRequest {
|
||||
options,
|
||||
parallelism,
|
||||
}),
|
||||
)])
|
||||
}
|
||||
|
||||
@@ -1332,6 +1341,7 @@ pub struct RegionFlushRequest {
|
||||
#[derive(Debug)]
|
||||
pub struct RegionCompactRequest {
|
||||
pub options: compact_request::Options,
|
||||
pub parallelism: Option<u32>,
|
||||
}
|
||||
|
||||
impl Default for RegionCompactRequest {
|
||||
@@ -1339,6 +1349,7 @@ impl Default for RegionCompactRequest {
|
||||
Self {
|
||||
// Default to regular compaction.
|
||||
options: compact_request::Options::Regular(Default::default()),
|
||||
parallelism: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user