-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-41677][CORE][SQL][SS][UI] Add Protobuf serializer for StreamingQueryProgressWrapper
#39642
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
19 commits
Select commit
Hold shift + click to select a range
eab4186
support StreamingQueryProgressWrapper
LuciferYang 3e6ade0
Merge branch 'upmaster' into SPARK-41677-2
LuciferYang fbbecf0
add comments
LuciferYang 8e89213
return JHashMap
LuciferYang d3f9ac0
Merge branch 'upmaster' into SPARK-41677-2
LuciferYang 6fe0163
Merge branch 'upmaster' into SPARK-41677-2
LuciferYang 3680d8b
Merge branch 'upmaster' into SPARK-41677-2
LuciferYang 198fcb2
handle null string
LuciferYang 5082846
id, runId to optional
LuciferYang c9275f6
Merge branch 'apache:master' into SPARK-41677-2
LuciferYang 9b3c19a
Merge branch 'upmaster' into SPARK-41677-2
LuciferYang a904a27
check null and test null map
LuciferYang 7566de4
Merge branch 'SPARK-41677-2' of github.com:LuciferYang/spark into SPA…
LuciferYang 699ebd1
setJMap
LuciferYang 061275c
rename f
LuciferYang e578627
revert java version
LuciferYang 81e39c8
use setJMapField
LuciferYang 480f48b
to a class private function
LuciferYang 6534fad
add comments
LuciferYang 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
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
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
44 changes: 44 additions & 0 deletions
44
sql/core/src/main/scala/org/apache/spark/status/protobuf/sql/SinkProgressSerializer.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,44 @@ | ||
| /* | ||
| * 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.sql | ||
|
|
||
| import java.util.{HashMap => JHashMap} | ||
|
|
||
| import org.apache.spark.sql.streaming.SinkProgress | ||
| import org.apache.spark.status.protobuf.StoreTypes | ||
| import org.apache.spark.status.protobuf.Utils.{getStringField, setStringField} | ||
|
|
||
| private[protobuf] object SinkProgressSerializer { | ||
|
|
||
| def serialize(sink: SinkProgress): StoreTypes.SinkProgress = { | ||
| import org.apache.spark.status.protobuf.Utils.setJMapField | ||
| val builder = StoreTypes.SinkProgress.newBuilder() | ||
| setStringField(sink.description, builder.setDescription) | ||
| builder.setNumOutputRows(sink.numOutputRows) | ||
| setJMapField(sink.metrics, builder.putAllMetrics) | ||
| builder.build() | ||
| } | ||
|
|
||
| def deserialize(sink: StoreTypes.SinkProgress): SinkProgress = { | ||
| new SinkProgress( | ||
| description = getStringField(sink.hasDescription, () => sink.getDescription), | ||
| numOutputRows = sink.getNumOutputRows, | ||
| metrics = new JHashMap(sink.getMetricsMap) | ||
| ) | ||
| } | ||
| } |
64 changes: 64 additions & 0 deletions
64
sql/core/src/main/scala/org/apache/spark/status/protobuf/sql/SourceProgressSerializer.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,64 @@ | ||
| /* | ||
| * 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.sql | ||
|
|
||
| import java.util.{HashMap => JHashMap, List => JList} | ||
|
|
||
| import org.apache.spark.sql.streaming.SourceProgress | ||
| import org.apache.spark.status.protobuf.StoreTypes | ||
| import org.apache.spark.status.protobuf.Utils.{getStringField, setJMapField, setStringField} | ||
|
|
||
| private[protobuf] object SourceProgressSerializer { | ||
|
|
||
| def serialize(source: SourceProgress): StoreTypes.SourceProgress = { | ||
| val builder = StoreTypes.SourceProgress.newBuilder() | ||
| setStringField(source.description, builder.setDescription) | ||
| setStringField(source.startOffset, builder.setStartOffset) | ||
| setStringField(source.endOffset, builder.setEndOffset) | ||
| setStringField(source.latestOffset, builder.setLatestOffset) | ||
| builder.setNumInputRows(source.numInputRows) | ||
| builder.setInputRowsPerSecond(source.inputRowsPerSecond) | ||
| builder.setProcessedRowsPerSecond(source.processedRowsPerSecond) | ||
| setJMapField(source.metrics, builder.putAllMetrics) | ||
| builder.build() | ||
| } | ||
|
|
||
| def deserializeToArray(sourceList: JList[StoreTypes.SourceProgress]): Array[SourceProgress] = { | ||
| val size = sourceList.size() | ||
| val result = new Array[SourceProgress](size) | ||
| var i = 0 | ||
| while (i < size) { | ||
| result(i) = deserialize(sourceList.get(i)) | ||
| i += 1 | ||
| } | ||
| result | ||
| } | ||
|
|
||
| private def deserialize(source: StoreTypes.SourceProgress): SourceProgress = { | ||
| new SourceProgress( | ||
| description = getStringField(source.hasDescription, () => source.getDescription), | ||
| startOffset = getStringField(source.hasStartOffset, () => source.getStartOffset), | ||
| endOffset = getStringField(source.hasEndOffset, () => source.getEndOffset), | ||
| latestOffset = getStringField(source.hasLatestOffset, () => source.getLatestOffset), | ||
| numInputRows = source.getNumInputRows, | ||
| inputRowsPerSecond = source.getInputRowsPerSecond, | ||
| processedRowsPerSecond = source.getProcessedRowsPerSecond, | ||
| metrics = new JHashMap(source.getMetricsMap) | ||
| ) | ||
| } | ||
| } |
76 changes: 76 additions & 0 deletions
76
...src/main/scala/org/apache/spark/status/protobuf/sql/StateOperatorProgressSerializer.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,76 @@ | ||
| /* | ||
| * 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.sql | ||
|
|
||
| import java.util.{HashMap => JHashMap, List => JList} | ||
|
|
||
| import org.apache.spark.sql.streaming.StateOperatorProgress | ||
| import org.apache.spark.status.protobuf.StoreTypes | ||
| import org.apache.spark.status.protobuf.Utils.{getStringField, setStringField} | ||
|
|
||
| object StateOperatorProgressSerializer { | ||
|
|
||
| def serialize(stateOperator: StateOperatorProgress): StoreTypes.StateOperatorProgress = { | ||
| import org.apache.spark.status.protobuf.Utils.setJMapField | ||
| val builder = StoreTypes.StateOperatorProgress.newBuilder() | ||
| setStringField(stateOperator.operatorName, builder.setOperatorName) | ||
| builder.setNumRowsTotal(stateOperator.numRowsTotal) | ||
| builder.setNumRowsUpdated(stateOperator.numRowsUpdated) | ||
| builder.setAllUpdatesTimeMs(stateOperator.allUpdatesTimeMs) | ||
| builder.setNumRowsRemoved(stateOperator.numRowsRemoved) | ||
| builder.setAllRemovalsTimeMs(stateOperator.allRemovalsTimeMs) | ||
| builder.setCommitTimeMs(stateOperator.commitTimeMs) | ||
| builder.setMemoryUsedBytes(stateOperator.memoryUsedBytes) | ||
| builder.setNumRowsDroppedByWatermark(stateOperator.numRowsDroppedByWatermark) | ||
| builder.setNumShufflePartitions(stateOperator.numShufflePartitions) | ||
| builder.setNumStateStoreInstances(stateOperator.numStateStoreInstances) | ||
| setJMapField(stateOperator.customMetrics, builder.putAllCustomMetrics) | ||
| builder.build() | ||
| } | ||
|
|
||
| def deserializeToArray( | ||
| stateOperatorList: JList[StoreTypes.StateOperatorProgress]): Array[StateOperatorProgress] = { | ||
| val size = stateOperatorList.size() | ||
| val result = new Array[StateOperatorProgress](size) | ||
| var i = 0 | ||
| while (i < size) { | ||
| result(i) = deserialize(stateOperatorList.get(i)) | ||
| i += 1 | ||
| } | ||
| result | ||
| } | ||
|
|
||
| private def deserialize( | ||
| stateOperator: StoreTypes.StateOperatorProgress): StateOperatorProgress = { | ||
| new StateOperatorProgress( | ||
| operatorName = | ||
| getStringField(stateOperator.hasOperatorName, () => stateOperator.getOperatorName), | ||
| numRowsTotal = stateOperator.getNumRowsTotal, | ||
| numRowsUpdated = stateOperator.getNumRowsUpdated, | ||
| allUpdatesTimeMs = stateOperator.getAllUpdatesTimeMs, | ||
| numRowsRemoved = stateOperator.getNumRowsRemoved, | ||
| allRemovalsTimeMs = stateOperator.getAllRemovalsTimeMs, | ||
| commitTimeMs = stateOperator.getCommitTimeMs, | ||
| memoryUsedBytes = stateOperator.getMemoryUsedBytes, | ||
| numRowsDroppedByWatermark = stateOperator.getNumRowsDroppedByWatermark, | ||
| numShufflePartitions = stateOperator.getNumShufflePartitions, | ||
| numStateStoreInstances = stateOperator.getNumStateStoreInstances, | ||
| customMetrics = new JHashMap(stateOperator.getCustomMetricsMap) | ||
| ) | ||
| } | ||
| } |
Oops, something went wrong.
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.
I am concerned about the nullability of all these maps. Shall we check/test all of them?
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.
a904a27 check/test all map
699ebd1 add
setJMapFieldfunction toUtils