-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-19008][SQL] Improve performance of Dataset.map by eliminating boxing/unboxing #17172
Closed
Closed
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d8b5f8d
Initial commit
kiszk a885907
fix scala style error
kiszk 65fa05a
Simplify scope of varibles as needed
kiszk 1f9ece4
add new benchmark suite with results
kiszk dfbce2a
address review comments
kiszk 8ee91af
support Boolean for returnType
kiszk 89c896e
add test cases for boolean type
kiszk 1fb2933
fix scala type failure
kiszk 35ba2c6
Generate a call to specialized method for Dataset.filter()
kiszk 4c88c03
update test cases for map()
kiszk 200cec7
add benchmark suite for Dataset.filter()
kiszk b25b191
update benchmark result
kiszk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ import org.apache.spark.sql.catalyst.plans.physical._ | |
import org.apache.spark.sql.Row | ||
import org.apache.spark.sql.catalyst.plans.logical.LogicalKeyedState | ||
import org.apache.spark.sql.execution.streaming.KeyedStateImpl | ||
import org.apache.spark.sql.types.{DataType, ObjectType, StructType} | ||
import org.apache.spark.sql.types._ | ||
|
||
|
||
/** | ||
|
@@ -219,7 +219,30 @@ case class MapElementsExec( | |
override def doConsume(ctx: CodegenContext, input: Seq[ExprCode], row: ExprCode): String = { | ||
val (funcClass, methodName) = func match { | ||
case m: MapFunction[_, _] => classOf[MapFunction[_, _]] -> "call" | ||
case _ => classOf[Any => Any] -> "apply" | ||
case _ => | ||
(if (child.output.length == 1) child.output(0).dataType else NullType, | ||
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. the |
||
outputObjAttr.dataType) match { | ||
// if a pair of an argument and return types is one of specific types | ||
// whose specialized method (apply$mc..$sp) is generated by scalac, | ||
// Catalyst generated a direct method call to the specialized method. | ||
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. can you link to some official document or blogpost? |
||
case (IntegerType, IntegerType) => classOf[Int => Int] -> "apply$mcII$sp" | ||
case (IntegerType, LongType) => classOf[Int => Long] -> "apply$mcJI$sp" | ||
case (IntegerType, FloatType) => classOf[Int => Float] -> "apply$mcFI$sp" | ||
case (IntegerType, DoubleType) => classOf[Int => Double] -> "apply$mcDI$sp" | ||
case (LongType, IntegerType) => classOf[Long => Int] -> "apply$mcIJ$sp" | ||
case (LongType, LongType) => classOf[Long => Long] -> "apply$mcJJ$sp" | ||
case (LongType, FloatType) => classOf[Long => Float] -> "apply$mcFJ$sp" | ||
case (LongType, DoubleType) => classOf[Long => Double] -> "apply$mcDJ$sp" | ||
case (FloatType, IntegerType) => classOf[Float => Int] -> "apply$mcIF$sp" | ||
case (FloatType, LongType) => classOf[Float => Long] -> "apply$mcJF$sp" | ||
case (FloatType, FloatType) => classOf[Float => Float] -> "apply$mcFF$sp" | ||
case (FloatType, DoubleType) => classOf[Float => Double] -> "apply$mcDF$sp" | ||
case (DoubleType, IntegerType) => classOf[Double => Int] -> "apply$mcID$sp" | ||
case (DoubleType, LongType) => classOf[Double => Long] -> "apply$mcJD$sp" | ||
case (DoubleType, FloatType) => classOf[Double => Float] -> "apply$mcFD$sp" | ||
case (DoubleType, DoubleType) => classOf[Double => Double] -> "apply$mcDD$sp" | ||
case _ => classOf[Any => Any] -> "apply" | ||
} | ||
} | ||
val funcObj = Literal.create(func, ObjectType(funcClass)) | ||
val callFunc = Invoke(funcObj, methodName, outputObjAttr.dataType, child.output) | ||
|
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
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.
let's put this thing in a util so that
FilterExec
can also use itThere 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.
Sure. Now, can generate a call to a specialized method for
Dataset.filter()
.