-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[Spark-21807][SQL]Override ++ operation in ExpressionSet to reduce clone time #19022
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
Changes from 8 commits
80af01a
7444a1c
1f5e0a3
88185ff
97803ce
8358351
6ee2ffd
57e8a3d
fec05d6
0762840
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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
|
|
||
| package org.apache.spark.sql.catalyst.expressions | ||
|
|
||
| import scala.collection.mutable | ||
| import scala.collection.{GenTraversableOnce, mutable} | ||
| import scala.collection.mutable.ArrayBuffer | ||
|
|
||
| object ExpressionSet { | ||
|
|
@@ -67,6 +67,12 @@ class ExpressionSet protected( | |
| newSet | ||
| } | ||
|
|
||
| override def ++(elems: GenTraversableOnce[Expression]): ExpressionSet = { | ||
| val newSet = new ExpressionSet(baseSet.clone(), originals.clone()) | ||
| elems.foreach(newSet.add) | ||
| newSet | ||
| } | ||
|
|
||
| override def -(elem: Expression): ExpressionSet = { | ||
|
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. I guess we don't use |
||
| val newBaseSet = baseSet.clone().filterNot(_ == elem.canonicalized) | ||
| val newOriginals = originals.clone().filterNot(_.canonicalized == elem.canonicalized) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,4 +210,13 @@ class ExpressionSetSuite extends SparkFunSuite { | |
| assert((initialSet - (aLower + 1)).size == 0) | ||
|
|
||
| } | ||
|
|
||
| test("add multiple elements to set") { | ||
|
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. This test case doesn't fail without the above code, does it?
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. Yap, previous |
||
| val initialSet = ExpressionSet(aUpper + 1 :: Nil) | ||
| val setToAddWithSameExpression = ExpressionSet(aUpper + 1 :: aUpper + 2 :: Nil) | ||
| val setToAdd = ExpressionSet(aUpper + 2 :: aUpper + 3 :: Nil) | ||
|
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. Not very sure what you want to test in the second one. Are you want to test the behavior of adding a set of expressions that do not exist in the initial set?
Contributor
Author
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. Yes, I have modified the name to setToAddWithOutSameExpression. |
||
|
|
||
| assert((initialSet ++ setToAddWithSameExpression).size == 2) | ||
| assert((initialSet ++ setToAdd).size == 3) | ||
| } | ||
| } | ||
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.
You can do style check by running
dev/scalastyle.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.
@eatoncys This breaks scala style check.
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.
Ok, modified it, thanks.