You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/12/21 02:52:50 UTC

[GitHub] [spark] LuciferYang opened a new pull request, #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

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

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


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


[GitHub] [spark] gengliangwang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054020774


##########
core/src/main/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializer.scala:
##########
@@ -17,39 +17,33 @@
 
 package org.apache.spark.status.protobuf
 
-import org.apache.spark.status._
+import java.util.ServiceLoader
+
+import collection.JavaConverters._
+
 import org.apache.spark.status.KVUtils.KVStoreScalaSerializer
 
 private[spark] class KVStoreProtobufSerializer extends KVStoreScalaSerializer {
-  override def serialize(o: Object): Array[Byte] = o match {
-    case j: JobDataWrapper => JobDataWrapperSerializer.
-      serialize(j)
-    case t: TaskDataWrapper => TaskDataWrapperSerializer.serialize(t)
-    case e: ExecutorStageSummaryWrapper => ExecutorStageSummaryWrapperSerializer.serialize(e)
-    case a: ApplicationEnvironmentInfoWrapper =>
-      ApplicationEnvironmentInfoWrapperSerializer.serialize(a)
-    case a: ApplicationInfoWrapper => ApplicationInfoWrapperSerializer.serialize(a)
-    case r: RDDStorageInfoWrapper =>
-      RDDStorageInfoWrapperSerializer.serialize(r)
-    case r: ResourceProfileWrapper => ResourceProfileWrapperSerializer.serialize(r)
-    case other => super.serialize(other)
-  }
-
-  override def deserialize[T](data: Array[Byte], klass: Class[T]): T = klass match {
-    case _ if classOf[JobDataWrapper].isAssignableFrom(klass) =>
-      JobDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[TaskDataWrapper].isAssignableFrom(klass) =>
-      TaskDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ExecutorStageSummaryWrapper].isAssignableFrom(klass) =>
-      ExecutorStageSummaryWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationEnvironmentInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationEnvironmentInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[RDDStorageInfoWrapper].isAssignableFrom(klass) =>
-      RDDStorageInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ResourceProfileWrapper].isAssignableFrom(klass) =>
-      ResourceProfileWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case other => super.deserialize(data, klass)
-  }
+  override def serialize(o: Object): Array[Byte] =
+    KVStoreProtobufSerializer.getSerializer(o.getClass) match {
+      case Some(serializer) => serializer.serialize(o)

Review Comment:
   Hmm I see. I don't know the solution either. Let's keep the current way and iterate the trait later.



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


[GitHub] [spark] LuciferYang commented on pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1360836939

   hmm... if all we care about is `So that we don't need to match classes with class name strings`,  we can let `supportClass` return `Class` type? Let me try
   
   
   
   
   
   


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


[GitHub] [spark] gengliangwang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054020774


##########
core/src/main/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializer.scala:
##########
@@ -17,39 +17,33 @@
 
 package org.apache.spark.status.protobuf
 
-import org.apache.spark.status._
+import java.util.ServiceLoader
+
+import collection.JavaConverters._
+
 import org.apache.spark.status.KVUtils.KVStoreScalaSerializer
 
 private[spark] class KVStoreProtobufSerializer extends KVStoreScalaSerializer {
-  override def serialize(o: Object): Array[Byte] = o match {
-    case j: JobDataWrapper => JobDataWrapperSerializer.
-      serialize(j)
-    case t: TaskDataWrapper => TaskDataWrapperSerializer.serialize(t)
-    case e: ExecutorStageSummaryWrapper => ExecutorStageSummaryWrapperSerializer.serialize(e)
-    case a: ApplicationEnvironmentInfoWrapper =>
-      ApplicationEnvironmentInfoWrapperSerializer.serialize(a)
-    case a: ApplicationInfoWrapper => ApplicationInfoWrapperSerializer.serialize(a)
-    case r: RDDStorageInfoWrapper =>
-      RDDStorageInfoWrapperSerializer.serialize(r)
-    case r: ResourceProfileWrapper => ResourceProfileWrapperSerializer.serialize(r)
-    case other => super.serialize(other)
-  }
-
-  override def deserialize[T](data: Array[Byte], klass: Class[T]): T = klass match {
-    case _ if classOf[JobDataWrapper].isAssignableFrom(klass) =>
-      JobDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[TaskDataWrapper].isAssignableFrom(klass) =>
-      TaskDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ExecutorStageSummaryWrapper].isAssignableFrom(klass) =>
-      ExecutorStageSummaryWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationEnvironmentInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationEnvironmentInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[RDDStorageInfoWrapper].isAssignableFrom(klass) =>
-      RDDStorageInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ResourceProfileWrapper].isAssignableFrom(klass) =>
-      ResourceProfileWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case other => super.deserialize(data, klass)
-  }
+  override def serialize(o: Object): Array[Byte] =
+    KVStoreProtobufSerializer.getSerializer(o.getClass) match {
+      case Some(serializer) => serializer.serialize(o)

Review Comment:
   Hmm I see. I don't know the solution either. Let's keep the current way and iterator the trait later.



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


[GitHub] [spark] gengliangwang commented on pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1360827887

   @LuciferYang how about the following two solutions:
   1. Use annotations. E.g. `ExecutorMetricsJsonSerializer`
   2. We can support registering in `KVStoreProtobufSerializer`, which is similar to `KryoSerializer`. 
   
   So that we don't need to match classes with class name strings.


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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053984935


##########
core/src/main/scala/org/apache/spark/status/protobuf/ApplicationEnvironmentInfoWrapperSerializer.scala:
##########
@@ -23,8 +23,14 @@ import org.apache.spark.resource.{ExecutorResourceRequest, TaskResourceRequest}
 import org.apache.spark.status.ApplicationEnvironmentInfoWrapper
 import org.apache.spark.status.api.v1.{ApplicationEnvironmentInfo, ResourceProfileInfo, RuntimeInfo}
 
-object ApplicationEnvironmentInfoWrapperSerializer {
-  def serialize(input: ApplicationEnvironmentInfoWrapper): Array[Byte] = {
+class ApplicationEnvironmentInfoWrapperSerializer extends ProtoBufSerDe {
+
+  override val supportClass: Class[_] = classOf[ApplicationEnvironmentInfoWrapper]
+
+  override def serialize(input: Any): Array[Byte] =

Review Comment:
   I'm not sure whether SPI can support generic type, but let me try
   
   



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


[GitHub] [spark] gengliangwang commented on a diff in pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtoBufSerDe` as SPI to make it easy for other modules to register serializers

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054032092


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   Shall we name it as `ProtobufSerde`? The `b` should be in lower case



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053934051


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   cc @gengliangwang, this pr introduce `ProtoBufSerDe` as a SPI to make it easier to add new `XXXSerializer` in other modules, such as add `SQLExecutionUIDataSerializer` and `SparkPlanGraphWrapperSerializer` to `sql` module.
   
   I think my work in https://github.com/apache/spark/pull/39139/files looks not elegant.
   
   Do you think it's worth to do? If so, I will file a new Jira as sub task of [SPARK-41053](https://issues.apache.org/jira/browse/SPARK-41053) and promote this work
   
   



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053934051


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   cc @gengliangwang, this pr introduce `ProtoBufSerDe` as a SPI to make it easier to add new `XXXSerializer` in other modules, such as add `SQLExecutionUIDataSerializer` and `SparkPlanGraphWrapperSerializer` to `sql` module.
   
   I think my work in [xx](https://github.com/apache/spark/pull/39139/files) looks not elegant.
   
   Do you think it's worth to do? If so, I will file a new Jira as sub task of [SPARK-41053](https://issues.apache.org/jira/browse/SPARK-41053) and promote this work
   
   



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054012625


##########
core/src/main/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializer.scala:
##########
@@ -17,39 +17,33 @@
 
 package org.apache.spark.status.protobuf
 
-import org.apache.spark.status._
+import java.util.ServiceLoader
+
+import collection.JavaConverters._
+
 import org.apache.spark.status.KVUtils.KVStoreScalaSerializer
 
 private[spark] class KVStoreProtobufSerializer extends KVStoreScalaSerializer {
-  override def serialize(o: Object): Array[Byte] = o match {
-    case j: JobDataWrapper => JobDataWrapperSerializer.
-      serialize(j)
-    case t: TaskDataWrapper => TaskDataWrapperSerializer.serialize(t)
-    case e: ExecutorStageSummaryWrapper => ExecutorStageSummaryWrapperSerializer.serialize(e)
-    case a: ApplicationEnvironmentInfoWrapper =>
-      ApplicationEnvironmentInfoWrapperSerializer.serialize(a)
-    case a: ApplicationInfoWrapper => ApplicationInfoWrapperSerializer.serialize(a)
-    case r: RDDStorageInfoWrapper =>
-      RDDStorageInfoWrapperSerializer.serialize(r)
-    case r: ResourceProfileWrapper => ResourceProfileWrapperSerializer.serialize(r)
-    case other => super.serialize(other)
-  }
-
-  override def deserialize[T](data: Array[Byte], klass: Class[T]): T = klass match {
-    case _ if classOf[JobDataWrapper].isAssignableFrom(klass) =>
-      JobDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[TaskDataWrapper].isAssignableFrom(klass) =>
-      TaskDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ExecutorStageSummaryWrapper].isAssignableFrom(klass) =>
-      ExecutorStageSummaryWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationEnvironmentInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationEnvironmentInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[RDDStorageInfoWrapper].isAssignableFrom(klass) =>
-      RDDStorageInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ResourceProfileWrapper].isAssignableFrom(klass) =>
-      ResourceProfileWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case other => super.deserialize(data, klass)
-  }
+  override def serialize(o: Object): Array[Byte] =
+    KVStoreProtobufSerializer.getSerializer(o.getClass) match {
+      case Some(serializer) => serializer.serialize(o)

Review Comment:
   If ProtoBufSerDe is defined as
   
   ```scala
   trait ProtoBufSerDe[T] {
   
     def serialize(input: T): Array[Byte]
   
     def deserialize(bytes: Array[Byte]): T
   }
   ```
   
   What datatype should `o` be `asInstanceOf` at line 29? `o` still an Object, I really didn't think clearly
   @gengliangwang @techaddict



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


[GitHub] [spark] LuciferYang commented on pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1360830039

   > @LuciferYang how about the following two solutions:
   > 
   > 1. Use annotations. E.g. `ExecutorMetricsJsonSerializer`
   > 2. We can support registering in `KVStoreProtobufSerializer`, which is similar to `KryoSerializer`.
   > 
   > So that we don't need to match classes with class name strings.
   
   Let me think more
   
   
   


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


[GitHub] [spark] gengliangwang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053983534


##########
core/src/main/scala/org/apache/spark/status/protobuf/ApplicationEnvironmentInfoWrapperSerializer.scala:
##########
@@ -23,8 +23,14 @@ import org.apache.spark.resource.{ExecutorResourceRequest, TaskResourceRequest}
 import org.apache.spark.status.ApplicationEnvironmentInfoWrapper
 import org.apache.spark.status.api.v1.{ApplicationEnvironmentInfo, ResourceProfileInfo, RuntimeInfo}
 
-object ApplicationEnvironmentInfoWrapperSerializer {
-  def serialize(input: ApplicationEnvironmentInfoWrapper): Array[Byte] = {
+class ApplicationEnvironmentInfoWrapperSerializer extends ProtoBufSerDe {
+
+  override val supportClass: Class[_] = classOf[ApplicationEnvironmentInfoWrapper]
+
+  override def serialize(input: Any): Array[Byte] =

Review Comment:
   Is it possible to change the `Any` here to be `ApplicationEnvironmentInfoWrapper`? The trait `ProtoBufSerDe` can become `ProtoBufSerDe[T]`.
   I haven't look into it closely. But if we can avoid the `asInstanceOf` here, the proposal looks good.
   
   



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053982998


##########
core/src/main/scala/org/apache/spark/status/protobuf/ResourceProfileWrapperSerializer.scala:
##########
@@ -18,19 +18,26 @@
 package org.apache.spark.status.protobuf
 
 import org.apache.spark.status.ResourceProfileWrapper
-import org.apache.spark.status.protobuf.ApplicationEnvironmentInfoWrapperSerializer.{deserializeResourceProfileInfo, serializeResourceProfileInfo}
 
-object ResourceProfileWrapperSerializer {
-  def serialize(input: ResourceProfileWrapper): Array[Byte] = {
+class ResourceProfileWrapperSerializer extends ProtoBufSerDe {
+
+  private val appEnvSerializer = new ApplicationEnvironmentInfoWrapperSerializer

Review Comment:
   We can move the required method to `object ResourceProfileWrapperSerializer`  to avoid creating `appEnvSerializer`
   
   



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053960416


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   Or we can split `ProtoBufSerDe ` into two trait:
   
   ```scala
   @DeveloperApi
   @Unstable
   trait ProtoBufSerDe {
   
     def serialize(input: Any): Array[Byte]
   
     def deserialize(bytes: Array[Byte]): Any
   }
   
   @DeveloperApi
   @Unstable
   trait ProtoBufSerializerProvider {
   
     val supportClass: String
     
     def createSerializer(): ProtoBufSerDe
   }
   ```
   
   and make `ProtoBufSerializerProvider` as SPI, and the demo `ProtoBufSerializerProvider` as follows:
   
   ```scala
   class RDDStorageInfoWrapperSerializerProvider extends ProtoBufSerializerProvider {
   
     override val supportClass: String = classOf[RDDStorageInfoWrapper].getName
   
     override def createSerializer(): ProtoBufSerDe = new RDDStorageInfoWrapperSerializer()
   }
   ```
   
   



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


[GitHub] [spark] LuciferYang commented on pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1360906165

   > @LuciferYang I am +1 on the current solution. Could you update the PR title and description?
   
   OK


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


[GitHub] [spark] gengliangwang commented on pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1360905064

   @LuciferYang I am +1 on the current solution. Could you update the PR title and description? 


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


[GitHub] [spark] LuciferYang commented on pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtobufSerDe` to make other modules easy to register `ProtoBufSerializer`

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1361139536

   GA passed


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


[GitHub] [spark] gengliangwang closed pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtobufSerDe` to make other modules easy to register `ProtoBufSerializer`

Posted by GitBox <gi...@apache.org>.
gengliangwang closed pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtobufSerDe` to make other modules easy to register `ProtoBufSerializer`
URL: https://github.com/apache/spark/pull/39148


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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053934051


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   cc @gengliangwang, this pr introduce `ProtoBufSerDe` as a SPI to make it easier to add new `XXXSerializer` in other modules, such as add `SQLExecutionUIDataSerializer` and `SparkPlanGraphWrapperSerializer` to `sql` module.
   
   I think my work in [xx](https://github.com/apache/spark/pull/39139/files) looks not elegant.
   
   Do you think it's worth to do? If so, I will file a new Jira as sub task of [SPARK-41053](https://issues.apache.org/jira/browse/SPARK-41053) and promote.
   
   



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


[GitHub] [spark] LuciferYang commented on pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1360841198

   Or is it because we don't want to register `ProtoBufSerDe` using SPI?
   
   


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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053983774


##########
core/src/main/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializer.scala:
##########
@@ -17,39 +17,33 @@
 
 package org.apache.spark.status.protobuf
 
-import org.apache.spark.status._
+import java.util.ServiceLoader
+
+import collection.JavaConverters._
+
 import org.apache.spark.status.KVUtils.KVStoreScalaSerializer
 
 private[spark] class KVStoreProtobufSerializer extends KVStoreScalaSerializer {
-  override def serialize(o: Object): Array[Byte] = o match {
-    case j: JobDataWrapper => JobDataWrapperSerializer.
-      serialize(j)
-    case t: TaskDataWrapper => TaskDataWrapperSerializer.serialize(t)
-    case e: ExecutorStageSummaryWrapper => ExecutorStageSummaryWrapperSerializer.serialize(e)
-    case a: ApplicationEnvironmentInfoWrapper =>
-      ApplicationEnvironmentInfoWrapperSerializer.serialize(a)
-    case a: ApplicationInfoWrapper => ApplicationInfoWrapperSerializer.serialize(a)
-    case r: RDDStorageInfoWrapper =>
-      RDDStorageInfoWrapperSerializer.serialize(r)
-    case r: ResourceProfileWrapper => ResourceProfileWrapperSerializer.serialize(r)
-    case other => super.serialize(other)
-  }
-
-  override def deserialize[T](data: Array[Byte], klass: Class[T]): T = klass match {
-    case _ if classOf[JobDataWrapper].isAssignableFrom(klass) =>
-      JobDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[TaskDataWrapper].isAssignableFrom(klass) =>
-      TaskDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ExecutorStageSummaryWrapper].isAssignableFrom(klass) =>
-      ExecutorStageSummaryWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationEnvironmentInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationEnvironmentInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[RDDStorageInfoWrapper].isAssignableFrom(klass) =>
-      RDDStorageInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ResourceProfileWrapper].isAssignableFrom(klass) =>
-      ResourceProfileWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case other => super.deserialize(data, klass)
-  }
+  override def serialize(o: Object): Array[Byte] =
+    KVStoreProtobufSerializer.getSerializer(o.getClass) match {
+      case Some(serializer) => serializer.serialize(o)
+      case _ => super.serialize(o)
+    }
+
+  override def deserialize[T](data: Array[Byte], klass: Class[T]): T =
+    KVStoreProtobufSerializer.getSerializer(klass) match {
+      case Some(serializer) =>
+        serializer.deserialize(data).asInstanceOf[T]
+      case _ => super.deserialize(data, klass)
+    }
+}
+
+private[spark] object KVStoreProtobufSerializer {
+
+ private[this] lazy val serializerMap: Map[Class[_], ProtoBufSerDe] =
+   ServiceLoader.load(classOf[ProtoBufSerDe])
+     .asScala.map(serDe => serDe.supportClass -> serDe).toMap
+
+  def getSerializer(klass: Class[_]): Option[ProtoBufSerDe] =

Review Comment:
   change `supportClass` to return `Class[_]` and match `ProtoBufSerDe` with `Class` instead of `class name strings`



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


[GitHub] [spark] LuciferYang commented on pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtobufSerDe` to make other modules easy to register `ProtoBufSerializer`

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1362306747

   Thanks @gengliangwang 


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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1053934836


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   also cc @techaddict 



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [DON'T MERGE] Introduce `ProtoBufSerDe` as a SPI

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054012625


##########
core/src/main/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializer.scala:
##########
@@ -17,39 +17,33 @@
 
 package org.apache.spark.status.protobuf
 
-import org.apache.spark.status._
+import java.util.ServiceLoader
+
+import collection.JavaConverters._
+
 import org.apache.spark.status.KVUtils.KVStoreScalaSerializer
 
 private[spark] class KVStoreProtobufSerializer extends KVStoreScalaSerializer {
-  override def serialize(o: Object): Array[Byte] = o match {
-    case j: JobDataWrapper => JobDataWrapperSerializer.
-      serialize(j)
-    case t: TaskDataWrapper => TaskDataWrapperSerializer.serialize(t)
-    case e: ExecutorStageSummaryWrapper => ExecutorStageSummaryWrapperSerializer.serialize(e)
-    case a: ApplicationEnvironmentInfoWrapper =>
-      ApplicationEnvironmentInfoWrapperSerializer.serialize(a)
-    case a: ApplicationInfoWrapper => ApplicationInfoWrapperSerializer.serialize(a)
-    case r: RDDStorageInfoWrapper =>
-      RDDStorageInfoWrapperSerializer.serialize(r)
-    case r: ResourceProfileWrapper => ResourceProfileWrapperSerializer.serialize(r)
-    case other => super.serialize(other)
-  }
-
-  override def deserialize[T](data: Array[Byte], klass: Class[T]): T = klass match {
-    case _ if classOf[JobDataWrapper].isAssignableFrom(klass) =>
-      JobDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[TaskDataWrapper].isAssignableFrom(klass) =>
-      TaskDataWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ExecutorStageSummaryWrapper].isAssignableFrom(klass) =>
-      ExecutorStageSummaryWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationEnvironmentInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationEnvironmentInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ApplicationInfoWrapper].isAssignableFrom(klass) =>
-      ApplicationInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[RDDStorageInfoWrapper].isAssignableFrom(klass) =>
-      RDDStorageInfoWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case _ if classOf[ResourceProfileWrapper].isAssignableFrom(klass) =>
-      ResourceProfileWrapperSerializer.deserialize(data).asInstanceOf[T]
-    case other => super.deserialize(data, klass)
-  }
+  override def serialize(o: Object): Array[Byte] =
+    KVStoreProtobufSerializer.getSerializer(o.getClass) match {
+      case Some(serializer) => serializer.serialize(o)

Review Comment:
   If ProtoBufSerDe is defined as
   
   ```scala
   trait ProtoBufSerDe[T] {
   
     def serialize(input: T): Array[Byte]
   
     def deserialize(bytes: Array[Byte]): T
   }
   ```
   
   What datatype should `o` be `asInstanceOf`? I really didn't think clearly
   @gengliangwang @techaddict



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


[GitHub] [spark] LuciferYang commented on a diff in pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtoBufSerDe` as SPI to make other module easy to register `ProtoBufSerializer`

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054033046


##########
core/src/main/scala/org/apache/spark/status/protobuf/ProtoBufSerDe.scala:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.status.protobuf
+
+import org.apache.spark.annotation.{DeveloperApi, Unstable}
+
+@DeveloperApi
+@Unstable
+trait ProtoBufSerDe {

Review Comment:
   OK



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


[GitHub] [spark] gengliangwang commented on a diff in pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtobufSerDe` to make other module easy to register `ProtoBufSerializer`

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on code in PR #39148:
URL: https://github.com/apache/spark/pull/39148#discussion_r1054035150


##########
core/src/main/scala/org/apache/spark/status/protobuf/RDDStorageInfoWrapperSerializer.scala:
##########
@@ -23,8 +23,13 @@ import org.apache.spark.status.RDDStorageInfoWrapper
 import org.apache.spark.status.api.v1.{RDDDataDistribution, RDDPartitionInfo, RDDStorageInfo}
 import org.apache.spark.status.protobuf.Utils.getOptional
 
-object RDDStorageInfoWrapperSerializer {
-  def serialize(input: RDDStorageInfoWrapper): Array[Byte] = {
+class RDDStorageInfoWrapperSerializer extends ProtoBufSerDe {
+
+  override val supportClass: Class[_] = classOf[RDDStorageInfoWrapper]
+
+  override def serialize(input: Any): Array[Byte] =
+    serialize(input.asInstanceOf[RDDStorageInfoWrapper])
+  private def serialize(input: RDDStorageInfoWrapper): Array[Byte] = {

Review Comment:
   nit: add one blank line



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


[GitHub] [spark] gengliangwang commented on pull request #39148: [SPARK-41644][CORE][UI] Introducing `ProtobufSerDe` to make other modules easy to register `ProtoBufSerializer`

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on PR #39148:
URL: https://github.com/apache/spark/pull/39148#issuecomment-1361794437

   Thanks, merging to the master branch


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