-
Notifications
You must be signed in to change notification settings - Fork 946
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
[compaction]Add local sample config for sort compaction #3081
Changes from 4 commits
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 |
---|---|---|
|
@@ -1056,6 +1056,12 @@ public class CoreOptions implements Serializable { | |
+ "If the data size allocated for the sorting task is uneven,which may lead to performance bottlenecks, " | ||
+ "the config can be set to size."); | ||
|
||
public static final ConfigOption<Integer> SORT_COMPACTION_LOCAL_SAMPLE_SIZE = | ||
key("sort-compaction.local-sample.size") | ||
.intType() | ||
.noDefaultValue() | ||
.withDescription( | ||
"The size of local sample for sort-compaction.By default,the value is the sink parallelism * 1000."); | ||
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. I think the parameter could be magnification. int localSampleSize = parallelism * magnification. magnification should be greater than or equal to 20 |
||
private final Options options; | ||
|
||
public CoreOptions(Map<String, String> options) { | ||
|
@@ -1126,6 +1132,10 @@ public boolean sortBySize() { | |
return options.get(SORT_RANG_STRATEGY) == RangeStrategy.SIZE; | ||
} | ||
|
||
public Optional<Integer> getLocalSampleSize() { | ||
return options.getOptional(SORT_COMPACTION_LOCAL_SAMPLE_SIZE); | ||
} | ||
|
||
public static FileFormat createFileFormat( | ||
Options options, ConfigOption<FileFormatType> formatOption) { | ||
String formatIdentifier = options.get(formatOption).toString(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,9 +99,18 @@ public static <KEY> DataStream<RowData> sortStreamByKey( | |
"The adaptive batch scheduler is not supported. Please set the sink parallelism using the key: " | ||
+ FlinkConnectorOptions.SINK_PARALLELISM.key()); | ||
} | ||
final int sampleSize = sinkParallelism * 1000; | ||
final int localSampleSize = | ||
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. localSampleSize = sinkParallelism * sampleSignification 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. done~ |
||
options.getLocalSampleSize().orElseGet(() -> sinkParallelism * 1000); | ||
final int globalSampleSize = sinkParallelism * 1000; | ||
final int rangeNum = sinkParallelism * 10; | ||
|
||
if (localSampleSize < 20) { | ||
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. if(localSampleSignification < 20) throws |
||
throw new IllegalArgumentException( | ||
String.format( | ||
"the config %s=%d is set too small,greater than or equal to 20 is needed.", | ||
CoreOptions.SORT_COMPACTION_LOCAL_SAMPLE_SIZE.key(), localSampleSize)); | ||
} | ||
|
||
int keyFieldCount = sortKeyType.getFieldCount(); | ||
int valueFieldCount = valueRowType.getFieldCount(); | ||
final int[] valueProjectionMap = new int[valueFieldCount]; | ||
|
@@ -144,7 +153,8 @@ public Tuple2<KEY, RowData> map(RowData value) { | |
inputWithKey, | ||
shuffleKeyComparator, | ||
keyTypeInformation, | ||
sampleSize, | ||
localSampleSize, | ||
globalSampleSize, | ||
rangeNum, | ||
sinkParallelism, | ||
valueRowType, | ||
|
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.
SORT_COMPACTION_SAMPLE_MAGNIFICATION