-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-41768][CORE] Refactor the definition of enum to follow with the code style #39286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
972ff8a
[SPARK-41768][CORE] Refactor the definition of enum - `JobExecutionSt…
panbingkun a913bd1
Merge branch 'master' into SPARK-41768
panbingkun bdca5f4
[SPARK-41768][CORE] Refactor the definition of enum - `JobExecutionSt…
panbingkun 8eff720
[SPARK-41768][CORE] Refactor the definition of enum - `JobExecutionSt…
panbingkun 0609a69
[SPARK-41768][CORE] Refactor the definition of enum - `JobExecutionSt…
panbingkun 92a8545
[SPARK-41768][CORE] Refactor the definition of enum to follow with th…
panbingkun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
core/src/main/scala/org/apache/spark/status/protobuf/JobExecutionStatusSerializer.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * 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.JobExecutionStatus | ||
| import org.apache.spark.status.protobuf.StoreTypes.{JobExecutionStatus => GJobExecutionStatus} | ||
|
|
||
| private[protobuf] object JobExecutionStatusSerializer { | ||
|
|
||
| def serialize(input: JobExecutionStatus): GJobExecutionStatus = { | ||
| input match { | ||
| case JobExecutionStatus.RUNNING => GJobExecutionStatus.JOB_EXECUTION_STATUS_RUNNING | ||
| case JobExecutionStatus.SUCCEEDED => GJobExecutionStatus.JOB_EXECUTION_STATUS_SUCCEEDED | ||
| case JobExecutionStatus.FAILED => GJobExecutionStatus.JOB_EXECUTION_STATUS_FAILED | ||
| case JobExecutionStatus.UNKNOWN => GJobExecutionStatus.JOB_EXECUTION_STATUS_UNKNOWN | ||
| } | ||
| } | ||
|
|
||
| def deserialize(binary: GJobExecutionStatus): JobExecutionStatus = { | ||
| binary match { | ||
| case GJobExecutionStatus.JOB_EXECUTION_STATUS_RUNNING => JobExecutionStatus.RUNNING | ||
| case GJobExecutionStatus.JOB_EXECUTION_STATUS_SUCCEEDED => JobExecutionStatus.SUCCEEDED | ||
| case GJobExecutionStatus.JOB_EXECUTION_STATUS_FAILED => JobExecutionStatus.FAILED | ||
| case GJobExecutionStatus.JOB_EXECUTION_STATUS_UNKNOWN => JobExecutionStatus.UNKNOWN | ||
| case _ => null | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import scala.collection.JavaConverters._ | |
|
|
||
| import org.apache.spark.rdd.DeterministicLevel | ||
| import org.apache.spark.status.{RDDOperationClusterWrapper, RDDOperationGraphWrapper} | ||
| import org.apache.spark.status.protobuf.StoreTypes.{DeterministicLevel => GDeterministicLevel} | ||
| import org.apache.spark.ui.scope.{RDDOperationEdge, RDDOperationNode} | ||
|
|
||
| class RDDOperationGraphWrapperSerializer extends ProtobufSerDe { | ||
|
|
@@ -81,8 +82,8 @@ class RDDOperationGraphWrapperSerializer extends ProtobufSerDe { | |
| } | ||
|
|
||
| private def serializeRDDOperationNode(node: RDDOperationNode): StoreTypes.RDDOperationNode = { | ||
| val outputDeterministicLevel = StoreTypes.RDDOperationNode.DeterministicLevel | ||
| .valueOf(node.outputDeterministicLevel.toString) | ||
| val outputDeterministicLevel = DeterministicLevelSerializer.serialize( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| node.outputDeterministicLevel) | ||
| val builder = StoreTypes.RDDOperationNode.newBuilder() | ||
| builder.setId(node.id) | ||
| builder.setName(node.name) | ||
|
|
@@ -100,8 +101,8 @@ class RDDOperationGraphWrapperSerializer extends ProtobufSerDe { | |
| cached = node.getCached, | ||
| barrier = node.getBarrier, | ||
| callsite = node.getCallsite, | ||
| outputDeterministicLevel = | ||
| DeterministicLevel.withName(node.getOutputDeterministicLevel.toString) | ||
| outputDeterministicLevel = DeterministicLevelSerializer.deserialize( | ||
| node.getOutputDeterministicLevel) | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -118,3 +119,29 @@ class RDDOperationGraphWrapperSerializer extends ProtobufSerDe { | |
| toId = edge.getToId) | ||
| } | ||
| } | ||
|
|
||
| private[protobuf] object DeterministicLevelSerializer { | ||
|
|
||
| def serialize(input: DeterministicLevel.Value): GDeterministicLevel = { | ||
| input match { | ||
| case DeterministicLevel.DETERMINATE => | ||
| GDeterministicLevel.DETERMINISTIC_LEVEL_DETERMINATE | ||
| case DeterministicLevel.UNORDERED => | ||
| GDeterministicLevel.DETERMINISTIC_LEVEL_UNORDERED | ||
| case DeterministicLevel.INDETERMINATE => | ||
| GDeterministicLevel.DETERMINISTIC_LEVEL_INDETERMINATE | ||
| } | ||
| } | ||
|
|
||
| def deserialize(binary: GDeterministicLevel): DeterministicLevel.Value = { | ||
| binary match { | ||
| case GDeterministicLevel.DETERMINISTIC_LEVEL_DETERMINATE => | ||
| DeterministicLevel.DETERMINATE | ||
| case GDeterministicLevel.DETERMINISTIC_LEVEL_UNORDERED => | ||
| DeterministicLevel.UNORDERED | ||
| case GDeterministicLevel.DETERMINISTIC_LEVEL_INDETERMINATE => | ||
| DeterministicLevel.INDETERMINATE | ||
| case _ => null | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels redundant to have the name in the enum class and in the constant name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srowen Yes, but we are following https://developers.google.com/protocol-buffers/docs/style#enums here. The purpose is to avoid naming conflicts. For example, if there is another enum containing
FAILEDorSUCCEEDED, the Protobuf compiler won't fail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok I get it