-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-2997] Support range partition with user customized data distribution. #1776
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c337073
Enable range partition with custom data distribution.
gallenvara 1970474
Modify the first test of range partition with two key fields.
gallenvara 7e2783f
Modify the test to validate the partitioning correctness.
gallenvara 0b8beaa
Modify the test with built-in data.
gallenvara d8d6c4b
Modify the test to avoid iterating.
gallenvara a2ec639
Move TestDataDist class into the test and modify the range boundary i…
gallenvara da3f857
Modify data distribution of the second test and check the partitions …
gallenvara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import java.util.Set; | ||
|
||
import org.apache.flink.api.common.ExecutionMode; | ||
import org.apache.flink.api.common.distributions.DataDistribution; | ||
import org.apache.flink.api.common.functions.Partitioner; | ||
import org.apache.flink.api.common.operators.Order; | ||
import org.apache.flink.api.common.operators.Ordering; | ||
|
@@ -55,6 +56,8 @@ public class GlobalProperties implements Cloneable { | |
|
||
private Partitioner<?> customPartitioner; | ||
|
||
private DataDistribution distribution; | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
|
@@ -80,16 +83,38 @@ public void setHashPartitioned(FieldList partitionedFields) { | |
this.partitioningFields = partitionedFields; | ||
this.ordering = null; | ||
} | ||
|
||
|
||
/** | ||
* Set the parameters for range partition. | ||
* | ||
* @param ordering Order of the partitioned fields | ||
*/ | ||
public void setRangePartitioned(Ordering ordering) { | ||
if (ordering == null) { | ||
throw new NullPointerException(); | ||
} | ||
|
||
this.partitioning = PartitioningProperty.RANGE_PARTITIONED; | ||
this.ordering = ordering; | ||
this.partitioningFields = ordering.getInvolvedIndexes(); | ||
} | ||
|
||
/** | ||
* Set the parameters for range partition. | ||
* | ||
* @param ordering Order of the partitioned fields | ||
* @param distribution The data distribution for range partition. User can supply a customized data distribution, | ||
* also the data distribution can be null. | ||
*/ | ||
public void setRangePartitioned(Ordering ordering, DataDistribution distribution) { | ||
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 know you've changed this part before, but could you add a |
||
if (ordering == null) { | ||
throw new NullPointerException(); | ||
} | ||
|
||
this.partitioning = PartitioningProperty.RANGE_PARTITIONED; | ||
this.ordering = ordering; | ||
this.partitioningFields = ordering.getInvolvedIndexes(); | ||
this.distribution = distribution; | ||
} | ||
|
||
public void setAnyPartitioning(FieldList partitionedFields) { | ||
|
@@ -167,6 +192,10 @@ public Partitioner<?> getCustomPartitioner() { | |
return this.customPartitioner; | ||
} | ||
|
||
public DataDistribution getDataDistribution() { | ||
return this.distribution; | ||
} | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
|
||
public boolean isPartitionedOnFields(FieldSet fields) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please add a check that a
distribution
is only set ifpMethod == PartitionMethod.RANGE
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.
Other
pMethod
likehashPartition
andcustomPartition
don't need thedistribution
and thedistribution
use its default value:null
, i think no check here also can make sense.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.
The check would prevent an invalid parameter combination and also shows readers of the code that such a combination is not valid. Hence, I think the check should be added.
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.
We should check here that the key types of
distribution.getKeyTypes()
are equal topKeys.getKeyFieldTypes()
.