ganeshashree commented on code in PR #57395:
URL: https://github.com/apache/spark/pull/57395#discussion_r3621963759


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/InMemoryRelation.scala:
##########
@@ -197,8 +197,11 @@ class DefaultCachedBatchSerializer extends 
SimpleMetricsCachedBatchSerializer {
       conf: SQLConf): RDD[ColumnarBatch] = {
     val offHeapColumnVectorEnabled = conf.offHeapColumnVectorEnabled
     val outputSchema = DataTypeUtils.fromAttributes(selectedAttributes)
+    // Build a single exprId -> ordinal map so each selected attribute is a 
constant-time lookup,
+    // instead of rebuilding the exprId list and linear-scanning it per 
selected attribute.
+    val cacheAttributeOrdinals = 
cacheAttributes.iterator.map(_.exprId).zipWithIndex.toMap

Review Comment:
   Done.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/InMemoryRelation.scala:
##########
@@ -230,10 +233,13 @@ class DefaultCachedBatchSerializer extends 
SimpleMetricsCachedBatchSerializer {
       cacheAttributes: Seq[Attribute],
       selectedAttributes: Seq[Attribute],
       conf: SQLConf): RDD[InternalRow] = {
-    // Find the ordinals and data types of the requested columns.
+    // Find the ordinals and data types of the requested columns. Build a 
single
+    // exprId -> ordinal map so each requested column is a constant-time 
lookup, instead of
+    // rebuilding the exprId list and linear-scanning it per requested column.
+    val cacheAttributeOrdinals = 
cacheAttributes.iterator.map(_.exprId).zipWithIndex.toMap

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to