-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-23207][SPARK-22905][SPARK-24564][SPARK-25114][SQL][BACKPORT-2.2] Shuffle+Repartition on a DataFrame could lead to incorrect answers #22079
Closed
+575
−30
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
495cba5
[SPARK-23207][SQL] Shuffle+Repartition on a DataFrame could lead to i…
jiangxb1987 8d2d558
Fix comment
bersprockets 81f57fe
[SPARK-23207][SQL][FOLLOW-UP] Don't perform local sort for DataFrame.…
jiangxb1987 bab8e68
[SPARK-22905][ML][FOLLOWUP] Fix GaussianMixtureModel save
zhengruifeng 754a454
[SPARK-24564][TEST] Add test suite for RecordBinaryComparator
jiangxb1987 2edad85
[SPARK-25114][CORE] Fix RecordBinaryComparator when subtraction betwe…
jiangxb1987 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 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 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 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 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 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 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 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 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 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 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
74 changes: 74 additions & 0 deletions
74
sql/catalyst/src/main/java/org/apache/spark/sql/execution/RecordBinaryComparator.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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.spark.sql.execution; | ||
|
||
import org.apache.spark.unsafe.Platform; | ||
import org.apache.spark.util.collection.unsafe.sort.RecordComparator; | ||
|
||
public final class RecordBinaryComparator extends RecordComparator { | ||
|
||
@Override | ||
public int compare( | ||
Object leftObj, long leftOff, int leftLen, Object rightObj, long rightOff, int rightLen) { | ||
int i = 0; | ||
|
||
// If the arrays have different length, the longer one is larger. | ||
if (leftLen != rightLen) { | ||
return leftLen - rightLen; | ||
} | ||
|
||
// The following logic uses `leftLen` as the length for both `leftObj` and `rightObj`, since | ||
// we have guaranteed `leftLen` == `rightLen`. | ||
|
||
// check if stars align and we can get both offsets to be aligned | ||
if ((leftOff % 8) == (rightOff % 8)) { | ||
while ((leftOff + i) % 8 != 0 && i < leftLen) { | ||
final int v1 = Platform.getByte(leftObj, leftOff + i) & 0xff; | ||
final int v2 = Platform.getByte(rightObj, rightOff + i) & 0xff; | ||
if (v1 != v2) { | ||
return v1 > v2 ? 1 : -1; | ||
} | ||
i += 1; | ||
} | ||
} | ||
// for architectures that support unaligned accesses, chew it up 8 bytes at a time | ||
if (Platform.unaligned() || (((leftOff + i) % 8 == 0) && ((rightOff + i) % 8 == 0))) { | ||
while (i <= leftLen - 8) { | ||
final long v1 = Platform.getLong(leftObj, leftOff + i); | ||
final long v2 = Platform.getLong(rightObj, rightOff + i); | ||
if (v1 != v2) { | ||
return v1 > v2 ? 1 : -1; | ||
} | ||
i += 8; | ||
} | ||
} | ||
// this will finish off the unaligned comparisons, or do the entire aligned comparison | ||
// whichever is needed. | ||
while (i < leftLen) { | ||
final int v1 = Platform.getByte(leftObj, leftOff + i) & 0xff; | ||
final int v2 = Platform.getByte(rightObj, rightOff + i) & 0xff; | ||
if (v1 != v2) { | ||
return v1 > v2 ? 1 : -1; | ||
} | ||
i += 1; | ||
} | ||
|
||
// The two arrays are equal. | ||
return 0; | ||
} | ||
} |
This file contains 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 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 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 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.
@jiangxb1987 and @bersprockets . SPARK-22905 consists of two commits.
If we want to include SPARK-22905 here, it had better be explicit and complete by putting
[SPARK-22905]
into the PR title and includes both patches.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.
@dongjoon-hyun Thanks, I will include the other commit and also update the title.