-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Feature][Zeta] Support Parallelism Inference #10102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
3fe6769
7265dec
598f3b9
4c745da
26c369c
0c955b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,4 +115,19 @@ public class EnvCommonOptions { | |
| .mapType() | ||
| .noDefaultValue() | ||
| .withDescription("Define the worker where the job runs by tag"); | ||
|
|
||
| // ==================== Parallelism Inference Options ==================== | ||
|
|
||
| public static Option<Boolean> PARALLELISM_INFERENCE_ENABLED = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New parameters need to be added in EnvOptionRule |
||
| Options.key("parallelism.inference.enabled") | ||
| .booleanType() | ||
| .defaultValue(false) | ||
| .withDescription("Enable automatic parallelism inference."); | ||
|
|
||
| public static Option<Integer> PARALLELISM_INFERENCE_MAX_PARALLELISM = | ||
| Options.key("parallelism.inference.max-parallelism") | ||
| .intType() | ||
| .defaultValue(64) | ||
| .withDescription( | ||
| "The maximum parallelism for operators when using automatic inference."); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.seatunnel.api.source; | ||
|
|
||
| /** | ||
| * The Source Connectors which support automatic parallelism inference should implement this | ||
| * interface. | ||
| */ | ||
| public interface SupportParallelismInference { | ||
|
|
||
| /** Infer the recommended parallelism for this source. */ | ||
| int inferParallelism(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| import org.apache.seatunnel.api.source.SeaTunnelSource; | ||
| import org.apache.seatunnel.api.source.SourceReader; | ||
| import org.apache.seatunnel.api.source.SourceSplitEnumerator; | ||
| import org.apache.seatunnel.api.source.SupportParallelismInference; | ||
| import org.apache.seatunnel.api.table.catalog.CatalogTable; | ||
| import org.apache.seatunnel.api.table.catalog.TablePath; | ||
| import org.apache.seatunnel.api.table.type.SeaTunnelRow; | ||
|
|
@@ -38,6 +39,7 @@ | |
| import org.apache.seatunnel.connectors.seatunnel.paimon.source.enumerator.PaimonStreamSourceSplitEnumerator; | ||
| import org.apache.seatunnel.connectors.seatunnel.paimon.utils.RowTypeConverter; | ||
|
|
||
| import org.apache.paimon.manifest.PartitionEntry; | ||
| import org.apache.paimon.predicate.Predicate; | ||
| import org.apache.paimon.table.FileStoreTable; | ||
| import org.apache.paimon.table.source.ReadBuilder; | ||
|
|
@@ -57,7 +59,8 @@ | |
| /** Paimon connector source class. */ | ||
| @Slf4j | ||
| public class PaimonSource | ||
| implements SeaTunnelSource<SeaTunnelRow, PaimonSourceSplit, PaimonSourceState> { | ||
| implements SeaTunnelSource<SeaTunnelRow, PaimonSourceSplit, PaimonSourceState>, | ||
| SupportParallelismInference { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
|
|
@@ -179,4 +182,32 @@ public SourceSplitEnumerator<PaimonSourceSplit, PaimonSourceState> restoreEnumer | |
| readBuilders, | ||
| 1); | ||
| } | ||
|
|
||
| /** Infer parallelism based on Paimon data partition count. */ | ||
| @Override | ||
| public int inferParallelism() { | ||
| int inferParallelism = 0; | ||
| try { | ||
| for (Map.Entry<String, ReadBuilder> entry : readBuilders.entrySet()) { | ||
| String tableKey = entry.getKey(); | ||
| ReadBuilder readBuilder = entry.getValue(); | ||
| try { | ||
| List<PartitionEntry> partitionEntries = | ||
| readBuilder.newScan().listPartitionEntries(); | ||
| inferParallelism += partitionEntries.size(); | ||
| } catch (Exception e) { | ||
| log.warn( | ||
| "Failed to get partition info for table {}, skipping parallelism inference", | ||
| tableKey, | ||
| e); | ||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| } catch (Exception e) { | ||
| log.warn("Failed to infer parallelism for Paimon source", e); | ||
| return -1; | ||
| } | ||
| return inferParallelism <= 0 ? 1 : inferParallelism; | ||
| } | ||
|
Comment on lines
+188
to
+212
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a problem with this design? Is there any recommended calculation rule for the parallelism of our Sink under normal circumstances? @Hisoka-X |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some priority notes