This is an automated email from the ASF dual-hosted git repository.
yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 37f2fa99c31d [SPARK-49408][SQL] Use IndexedSeq in ProjectingInternalRow
37f2fa99c31d is described below
commit 37f2fa99c31d7563f4020557fc50b74d7cb758bc
Author: wzx <[email protected]>
AuthorDate: Thu Sep 5 14:58:15 2024 +0800
[SPARK-49408][SQL] Use IndexedSeq in ProjectingInternalRow
### What changes were proposed in this pull request?
In ProjectingInternalRow, accessing colOrdinals causes poor performace.
Replace colOrdinals with the IndexedSeq type.
### Why are the changes needed?
Replace colOrdinals with the IndexedSeq type.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
No need to add UT
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #47890 from wzx140/project-row-fix.
Lead-authored-by: wzx <[email protected]>
Co-authored-by: Kent Yao <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
---
.../org/apache/spark/sql/catalyst/ProjectingInternalRow.scala | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ProjectingInternalRow.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ProjectingInternalRow.scala
index 408bd65333ca..20cf80e88e42 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ProjectingInternalRow.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ProjectingInternalRow.scala
@@ -26,7 +26,8 @@ import org.apache.spark.unsafe.types.{CalendarInterval,
UTF8String, VariantVal}
* An [[InternalRow]] that projects particular columns from another
[[InternalRow]] without copying
* the underlying data.
*/
-case class ProjectingInternalRow(schema: StructType, colOrdinals: Seq[Int])
extends InternalRow {
+case class ProjectingInternalRow(schema: StructType,
+ colOrdinals: IndexedSeq[Int]) extends InternalRow {
assert(schema.size == colOrdinals.size)
private var row: InternalRow = _
@@ -116,3 +117,9 @@ case class ProjectingInternalRow(schema: StructType,
colOrdinals: Seq[Int]) exte
row.get(colOrdinals(ordinal), dataType)
}
}
+
+object ProjectingInternalRow {
+ def apply(schema: StructType, colOrdinals: Seq[Int]): ProjectingInternalRow
= {
+ new ProjectingInternalRow(schema, colOrdinals.toIndexedSeq)
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]