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 2023/12/05 07:08:24 UTC

[PR] [SPARK-46263][CORE][SQL][MLLIB] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions. [spark]

LuciferYang opened a new pull request, #44179:
URL: https://github.com/apache/spark/pull/44179

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions. [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #44179:
URL: https://github.com/apache/spark/pull/44179#issuecomment-1840132785

   Let me double check the change first


-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #44179:
URL: https://github.com/apache/spark/pull/44179#issuecomment-1842120583

   Thanks @yaooqinn @dongjoon-hyun @zhengruifeng ~


-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415263533


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   No, The `.toSeq` will trigger computation, so this view doesn't achieve its intended effect, unless we refactor the truncatedString method to accept SeqView instead of Seq.



##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   No, The `.toSeq` will trigger computation, so this view doesn't achieve its intended effect, unless we refactor the truncatedString method to accept SeqView instead of Seq.



##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   No, The `.toSeq` will trigger computation, so this view doesn't achieve its intended effect, unless we refactor the truncatedString method to accept `SeqView` instead of `Seq`.



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415263533


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   No, The `.toSeq` will trigger computation, so this view doesn't achieve its intended effect, unless we refactor the `truncatedString` method to accept `SeqView` instead of `Seq`.



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415517518


##########
core/src/main/scala/org/apache/spark/ui/UIUtils.scala:
##########
@@ -431,7 +431,7 @@ private[spark] object UIUtils extends Logging {
     }
 
     val headerRow: Seq[Node] = {
-      headers.view.zipWithIndex.map { x =>
+      headers.zipWithIndex.map { x =>

Review Comment:
   https://github.com/apache/spark/pull/2867/files#diff-809c93c57cc59e5fe3c3eb54a24aa96a38147d02323f3e690ae6b5309a3284d2
   
   ![image](https://github.com/apache/spark/assets/1475305/d92f444c-4fe7-455c-9416-0785a5d93d27)
   
   seems that the initial intention here was also to consciously use a lazy view, also test the LazyList



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415256193


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   Is creating a view for lazy transformation better as we have maxToStringFields limits?



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415496286


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLog.scala:
##########
@@ -388,7 +388,7 @@ object CompactibleFileStreamLog {
     } else if (defaultInterval < (latestCompactBatchId + 1) / 2) {
       // Find the first divisor >= default compact interval
       def properDivisors(min: Int, n: Int) =
-        (min to n/2).view.filter(i => n % i == 0).toSeq :+ n
+        (min to n / 2).to(LazyList).filter(i => n % i == 0) :+ n

Review Comment:
   @yaooqinn 
   https://github.com/apache/spark/pull/15852/files#diff-ed29e1893fa3939724b333684e1f6037358b3d7edce1e3663afdda8d99002fed
   
   ![image](https://github.com/apache/spark/assets/1475305/03e8f4dc-cada-48de-8d8d-206ad1dc6d83)
   
   seems that the initial intention here was also to use a lazy view, test `LazyList`
   
   
   



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415266748


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   If we want to do this refactor for `SparkStringUtils#truncatedString` function, I can revert this change and create a Jira to track it.
   
   



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415455947


##########
mllib/src/main/scala/org/apache/spark/mllib/clustering/GaussianMixture.scala:
##########
@@ -187,7 +187,7 @@ class GaussianMixture private (
       case None =>
         val samples = breezeData.takeSample(withReplacement = true, k * nSamples, seed)
         (Array.fill(k)(1.0 / k), Array.tabulate(k) { i =>
-          val slice = samples.view.slice(i * nSamples, (i + 1) * nSamples)
+          val slice = samples.slice(i * nSamples, (i + 1) * nSamples)

Review Comment:
   also cc @zhengruifeng could you help review the changes in mllib, thanks 
   
   



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415981487


##########
core/src/main/scala/org/apache/spark/ui/UIUtils.scala:
##########
@@ -431,7 +431,7 @@ private[spark] object UIUtils extends Logging {
     }
 
     val headerRow: Seq[Node] = {
-      headers.view.zipWithIndex.map { x =>
+      headers.to(LazyList).zipWithIndex.map { x =>

Review Comment:
   When using Scala 2.12, it is lazy, so I prefer to use LazyList to restore its lazy characteristics with Scala 2.13
   
   



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #44179:
URL: https://github.com/apache/spark/pull/44179#issuecomment-1840380311

   Could you review this PR? @cloud-fan @dongjoon-hyun @yaooqinn 
   
   


-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415263533


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   No, The `.toSeq` will trigger computation, so this view doesn't achieve its intended effect, unless we refactor the truncatedString method to accept `SeqView` instead of `Seq`.



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415266748


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   If we want to do this refactor for `SparkStringUtils#truncatedString` function, I can revert this change and create a Jira to track it."
   
   



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on PR #44179:
URL: https://github.com/apache/spark/pull/44179#issuecomment-1842108945

   Thanks @LuciferYang @dongjoon-hyun @zhengruifeng 
   
   Merged to master


-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415331079


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   Got, let me test to use `LazyList` here



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415983554


##########
core/src/main/scala/org/apache/spark/ui/UIUtils.scala:
##########
@@ -431,7 +431,7 @@ private[spark] object UIUtils extends Logging {
     }
 
     val headerRow: Seq[Node] = {
-      headers.view.zipWithIndex.map { x =>
+      headers.to(LazyList).zipWithIndex.map { x =>

Review Comment:
   Thank you for the answer, @LuciferYang .



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #44179:
URL: https://github.com/apache/spark/pull/44179#issuecomment-1842024051

   Thanks @dongjoon-hyun ~ 
   
   Could you take another look? @yaooqinn Thanks ~


-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415490110


##########
mllib/src/main/scala/org/apache/spark/mllib/clustering/GaussianMixture.scala:
##########
@@ -187,7 +187,7 @@ class GaussianMixture private (
       case None =>
         val samples = breezeData.takeSample(withReplacement = true, k * nSamples, seed)
         (Array.fill(k)(1.0 / k), Array.tabulate(k) { i =>
-          val slice = samples.view.slice(i * nSamples, (i + 1) * nSamples)
+          val slice = samples.slice(i * nSamples, (i + 1) * nSamples)

Review Comment:
   thanks @zhengruifeng 



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415318597


##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -417,7 +417,7 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
   override def defaultSize: Int = fields.map(_.dataType.defaultSize).sum
 
   override def simpleString: String = {
-    val fieldTypes = fields.view.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq
+    val fieldTypes = fields.map(field => s"${field.name}:${field.dataType.simpleString}").toSeq

Review Comment:
   I guess the `view` was added here first for performance consideration. Later, the `toSeq` was added for compatibility with Scala 2.13, breaking the original intention.



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415496286


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/CompactibleFileStreamLog.scala:
##########
@@ -388,7 +388,7 @@ object CompactibleFileStreamLog {
     } else if (defaultInterval < (latestCompactBatchId + 1) / 2) {
       // Find the first divisor >= default compact interval
       def properDivisors(min: Int, n: Int) =
-        (min to n/2).view.filter(i => n % i == 0).toSeq :+ n
+        (min to n / 2).to(LazyList).filter(i => n % i == 0) :+ n

Review Comment:
   @yaooqinn 
   https://github.com/apache/spark/pull/15852/files#diff-ed29e1893fa3939724b333684e1f6037358b3d7edce1e3663afdda8d99002fed
   
   ![image](https://github.com/apache/spark/assets/1475305/03e8f4dc-cada-48de-8d8d-206ad1dc6d83)
   
   seems that the initial intention here was also to use a lazy view
   
   
   



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up unnecessary `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415479079


##########
mllib/src/main/scala/org/apache/spark/mllib/clustering/GaussianMixture.scala:
##########
@@ -187,7 +187,7 @@ class GaussianMixture private (
       case None =>
         val samples = breezeData.takeSample(withReplacement = true, k * nSamples, seed)
         (Array.fill(k)(1.0 / k), Array.tabulate(k) { i =>
-          val slice = samples.view.slice(i * nSamples, (i + 1) * nSamples)
+          val slice = samples.slice(i * nSamples, (i + 1) * nSamples)

Review Comment:
   the ML part should be fine if all tests pass



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415952748


##########
mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Entropy.scala:
##########
@@ -112,7 +112,7 @@ private[spark] class EntropyAggregator(numClasses: Int)
    * @param offset    Start index of stats for this (node, feature, bin).
    */
   def getCalculator(allStats: Array[Double], offset: Int): EntropyCalculator = {
-    new EntropyCalculator(allStats.view.slice(offset, offset + statsSize - 1).toArray,
+    new EntropyCalculator(allStats.slice(offset, offset + statsSize - 1),

Review Comment:
   This kind of simple replacements looks good definitely.



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #44179:
URL: https://github.com/apache/spark/pull/44179#discussion_r1415950533


##########
core/src/main/scala/org/apache/spark/ui/UIUtils.scala:
##########
@@ -431,7 +431,7 @@ private[spark] object UIUtils extends Logging {
     }
 
     val headerRow: Seq[Node] = {
-      headers.view.zipWithIndex.map { x =>
+      headers.to(LazyList).zipWithIndex.map { x =>

Review Comment:
   Just a question. Is this better?



-- 
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


Re: [PR] [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions [spark]

Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn closed pull request #44179: [SPARK-46263][SQL][SS][ML][MLLIB][UI] Clean up `SeqOps.view` and `ArrayOps.view` conversions
URL: https://github.com/apache/spark/pull/44179


-- 
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