You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2024/08/08 07:34:27 UTC
Re: [PR] [SPARK-][CORE][SQL][CONNECT][ML][R][TESTS] Change the target type of encoding `ArrayType` from `mutable.ArraySeq` to `immutable.ArraySeq` in Spark internals [spark]
LuciferYang commented on code in PR #47664:
URL: https://github.com/apache/spark/pull/47664#discussion_r1708808529
##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/encoders/RowEncoder.scala:
##########
@@ -106,7 +106,7 @@ object RowEncoder extends DataTypeErrorsBase {
UDTEncoder(udt, udtClass.asInstanceOf[Class[_ <: UserDefinedType[_]]])
case ArrayType(elementType, containsNull) =>
IterableEncoder(
- classTag[mutable.ArraySeq[_]],
+ classTag[immutable.ArraySeq[_]],
Review Comment:
https://github.com/apache/spark/blob/af70aafd330fdbb6ce0d5b3efbcb180cda488695/sql/api/src/main/scala/org/apache/spark/sql/Row.scala#L317-L325
The change is to avoid the frequent collection copying when calling `row.getSeq`(`mutable.Seq` -> `immutable.Seq`), which can be costly especially when the collection itself is large."
After ArrayType encoding as `immutable.ArraySeq`, the delay of `getSeq` will become a constant, whereas before (encoding as `mutable.ArraySeq`), the delay of `getSeq` will increase linearly with the length of the `Seq` itself.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org