Xiao-zhen-Liu commented on code in PR #9271:
URL: https://github.com/apache/texera/pull/9271#discussion_r4555105552
##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala:
##########
@@ -403,53 +414,48 @@ class ExecutionResultService(
val allTableStats = mutable.Map[String, Map[String, Map[String,
Any]]]()
newState.resultInfo
.filter(info => {
- // only update those operators with changing tuple count.
+ // only update those output ports with changing tuple count.
!oldState.resultInfo
.contains(info._1) || oldState.resultInfo(info._1).tupleCount !=
info._2.tupleCount
})
.foreach {
- case (opId, info) =>
- val oldInfo = oldState.resultInfo.getOrElse(opId,
OperatorResultMetadata())
- buf(opId.id) = ExecutionResultService.convertWebResultUpdate(
- workflowIdentity,
- executionId,
- physicalPlan.getPhysicalOpsOfLogicalOp(opId),
- oldInfo.tupleCount,
- info.tupleCount
- )
- // using the first port for now. TODO: support multiple ports
- val outputPortsMap = physicalPlan
- .getPhysicalOpsOfLogicalOp(opId)
- .headOption
- .map(_.outputPorts)
- .getOrElse(Map.empty)
- val hasSingleSnapshot = outputPortsMap.values.exists {
- case (outputPort, _, _) =>
- // SINGLE_SNAPSHOT is used for HTML content
- outputPort.mode == OutputMode.SINGLE_SNAPSHOT
+ case (globalPortId, info) =>
+ val opId = globalPortId.opId.logicalOpId
+ val portId = globalPortId.portId
+ val oldInfo = oldState.resultInfo.getOrElse(globalPortId,
OperatorResultMetadata())
+ val outputMode =
ExecutionResultService.outputModeOf(physicalPlan, opId, portId)
+ val isFirstPort = portId == PortIdentity()
+ // the result updates are about each operator's first output port
+ if (isFirstPort) {
+ buf(opId.id) = ExecutionResultService.convertWebResultUpdate(
+ workflowIdentity,
+ executionId,
+ opId,
+ portId,
+ outputMode,
+ oldInfo.tupleCount,
+ info.tupleCount
+ )
}
- if (!hasSingleSnapshot) {
- val storageUri = WorkflowExecutionsResource
- .getResultUriByLogicalPortId(
- executionId,
- opId,
- PortIdentity()
- )
-
- if (storageUri.nonEmpty) {
- val globalPortIdOption =
VFSURIFactory.decodeURI(storageUri.get).globalPortId
- val opStorage =
DocumentFactory.openDocument(storageUri.get)._1
-
- allTableStats(opId.id) = opStorage.getTableStatistics
- WorkflowExecutionsResource.updateResultSize(
- executionId,
- globalPortIdOption.get,
- opStorage.getTotalFileSize
- )
-
WorkflowExecutionsResource.updateRuntimeStatsSize(executionId)
-
WorkflowExecutionsResource.updateConsoleMessageSize(executionId, opId)
- }
+ // SINGLE_SNAPSHOT is used for HTML content, which is not a table
+ if (outputMode != OutputMode.SINGLE_SNAPSHOT) {
+ WorkflowExecutionsResource
+ .getResultUriByLogicalPortId(executionId, opId, portId)
+ .foreach { storageUri =>
+ val opStorage = DocumentFactory.openDocument(storageUri)._1
+ // the table statistics are the first port's, as the
result updates are
+ if (isFirstPort) {
+ allTableStats(opId.id) = opStorage.getTableStatistics
+ }
+ WorkflowExecutionsResource.updateResultSize(
+ executionId,
+ VFSURIFactory.decodeURI(storageUri).globalPortId.get,
+ opStorage.getTotalFileSize
+ )
+
WorkflowExecutionsResource.updateRuntimeStatsSize(executionId)
+
WorkflowExecutionsResource.updateConsoleMessageSize(executionId, opId)
+ }
Review Comment:
Nit: We can pass the port identifier already bound at the top of the loop
here instead of decoding the storage URI again. Also, since this loop runs once
per changed output port rather than once per operator, could we move the
execution-wide runtime statistics size update and per-operator console message
size update outside the per-port work so they run once per poll and once per
changed operator?
##########
amber/src/test/scala/org/apache/texera/web/service/ExecutionResultServiceSpec.scala:
##########
@@ -1262,30 +1529,61 @@ class ExecutionResultServiceSpec
polling.cancelCount shouldBe 1
val resultInfo =
fixture.workflowStateStore.resultStore.getState.resultInfo
- resultInfo.keySet.map(_.id) shouldBe Set("erss-final-snapshot",
"erss-final-delta")
+ resultInfo.keySet shouldBe Set(
+ globalPortIdOf("erss-final-snapshot"),
+ globalPortIdOf("erss-final-delta")
+ )
// Counts come from the documents themselves, so the two operators must
not
// be reported with the same count.
- resultInfo(OperatorIdentity("erss-final-snapshot")).tupleCount shouldBe 3
- resultInfo(OperatorIdentity("erss-final-delta")).tupleCount shouldBe 2
+ resultInfo(globalPortIdOf("erss-final-snapshot")).tupleCount shouldBe 3
+ resultInfo(globalPortIdOf("erss-final-delta")).tupleCount shouldBe 2
// A SET_SNAPSHOT result is replaced wholesale, so its content can change
// without its count changing; the random change detector is what makes
the
// frontend re-read it. A delta is append-only and needs no such nudge.
- resultInfo(OperatorIdentity("erss-final-snapshot")).changeDetector
should not be empty
- resultInfo(OperatorIdentity("erss-final-delta")).changeDetector shouldBe
""
+ resultInfo(globalPortIdOf("erss-final-snapshot")).changeDetector should
not be empty
+ resultInfo(globalPortIdOf("erss-final-delta")).changeDetector shouldBe ""
Review Comment:
Nit: This comment says the random change detector makes the frontend re-read
a snapshot result whose row count did not change, which seems to conflict with
the test at line 1317 ("not resend a port whose count is unchanged but whose
change detector moved") and the diff handler filter that compares row counts
only. Could we update the comment so it matches what the diff handler checks?
##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala:
##########
@@ -403,53 +414,48 @@ class ExecutionResultService(
val allTableStats = mutable.Map[String, Map[String, Map[String,
Any]]]()
newState.resultInfo
.filter(info => {
- // only update those operators with changing tuple count.
+ // only update those output ports with changing tuple count.
!oldState.resultInfo
.contains(info._1) || oldState.resultInfo(info._1).tupleCount !=
info._2.tupleCount
})
.foreach {
- case (opId, info) =>
- val oldInfo = oldState.resultInfo.getOrElse(opId,
OperatorResultMetadata())
- buf(opId.id) = ExecutionResultService.convertWebResultUpdate(
- workflowIdentity,
- executionId,
- physicalPlan.getPhysicalOpsOfLogicalOp(opId),
- oldInfo.tupleCount,
- info.tupleCount
- )
- // using the first port for now. TODO: support multiple ports
- val outputPortsMap = physicalPlan
- .getPhysicalOpsOfLogicalOp(opId)
- .headOption
- .map(_.outputPorts)
- .getOrElse(Map.empty)
- val hasSingleSnapshot = outputPortsMap.values.exists {
- case (outputPort, _, _) =>
- // SINGLE_SNAPSHOT is used for HTML content
- outputPort.mode == OutputMode.SINGLE_SNAPSHOT
+ case (globalPortId, info) =>
+ val opId = globalPortId.opId.logicalOpId
+ val portId = globalPortId.portId
+ val oldInfo = oldState.resultInfo.getOrElse(globalPortId,
OperatorResultMetadata())
+ val outputMode =
ExecutionResultService.outputModeOf(physicalPlan, opId, portId)
+ val isFirstPort = portId == PortIdentity()
+ // the result updates are about each operator's first output port
+ if (isFirstPort) {
+ buf(opId.id) = ExecutionResultService.convertWebResultUpdate(
+ workflowIdentity,
+ executionId,
+ opId,
+ portId,
+ outputMode,
+ oldInfo.tupleCount,
+ info.tupleCount
+ )
}
- if (!hasSingleSnapshot) {
- val storageUri = WorkflowExecutionsResource
- .getResultUriByLogicalPortId(
- executionId,
- opId,
- PortIdentity()
- )
-
- if (storageUri.nonEmpty) {
- val globalPortIdOption =
VFSURIFactory.decodeURI(storageUri.get).globalPortId
- val opStorage =
DocumentFactory.openDocument(storageUri.get)._1
-
- allTableStats(opId.id) = opStorage.getTableStatistics
- WorkflowExecutionsResource.updateResultSize(
- executionId,
- globalPortIdOption.get,
- opStorage.getTotalFileSize
- )
-
WorkflowExecutionsResource.updateRuntimeStatsSize(executionId)
-
WorkflowExecutionsResource.updateConsoleMessageSize(executionId, opId)
- }
+ // SINGLE_SNAPSHOT is used for HTML content, which is not a table
+ if (outputMode != OutputMode.SINGLE_SNAPSHOT) {
+ WorkflowExecutionsResource
+ .getResultUriByLogicalPortId(executionId, opId, portId)
+ .foreach { storageUri =>
+ val opStorage = DocumentFactory.openDocument(storageUri)._1
+ // the table statistics are the first port's, as the
result updates are
+ if (isFirstPort) {
+ allTableStats(opId.id) = opStorage.getTableStatistics
+ }
+ WorkflowExecutionsResource.updateResultSize(
Review Comment:
When an operator has multiple output ports such as Split, branching on
whether an output port is port 0 sends result updates and table statistics only
for port 0 and drops them for port 1 (and in #9272 still skips table statistics
for port 1). Could we remove the port-0 branch and key both maps by operator
and port index so every output port goes through the same update and statistics
path?
##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala:
##########
@@ -403,53 +414,48 @@ class ExecutionResultService(
val allTableStats = mutable.Map[String, Map[String, Map[String,
Any]]]()
newState.resultInfo
.filter(info => {
- // only update those operators with changing tuple count.
+ // only update those output ports with changing tuple count.
!oldState.resultInfo
.contains(info._1) || oldState.resultInfo(info._1).tupleCount !=
info._2.tupleCount
})
.foreach {
- case (opId, info) =>
- val oldInfo = oldState.resultInfo.getOrElse(opId,
OperatorResultMetadata())
- buf(opId.id) = ExecutionResultService.convertWebResultUpdate(
- workflowIdentity,
- executionId,
- physicalPlan.getPhysicalOpsOfLogicalOp(opId),
- oldInfo.tupleCount,
- info.tupleCount
- )
- // using the first port for now. TODO: support multiple ports
- val outputPortsMap = physicalPlan
- .getPhysicalOpsOfLogicalOp(opId)
- .headOption
- .map(_.outputPorts)
- .getOrElse(Map.empty)
- val hasSingleSnapshot = outputPortsMap.values.exists {
- case (outputPort, _, _) =>
- // SINGLE_SNAPSHOT is used for HTML content
- outputPort.mode == OutputMode.SINGLE_SNAPSHOT
+ case (globalPortId, info) =>
+ val opId = globalPortId.opId.logicalOpId
+ val portId = globalPortId.portId
+ val oldInfo = oldState.resultInfo.getOrElse(globalPortId,
OperatorResultMetadata())
+ val outputMode =
ExecutionResultService.outputModeOf(physicalPlan, opId, portId)
+ val isFirstPort = portId == PortIdentity()
+ // the result updates are about each operator's first output port
+ if (isFirstPort) {
+ buf(opId.id) = ExecutionResultService.convertWebResultUpdate(
+ workflowIdentity,
+ executionId,
+ opId,
+ portId,
+ outputMode,
+ oldInfo.tupleCount,
+ info.tupleCount
+ )
}
- if (!hasSingleSnapshot) {
- val storageUri = WorkflowExecutionsResource
- .getResultUriByLogicalPortId(
- executionId,
- opId,
- PortIdentity()
- )
-
- if (storageUri.nonEmpty) {
- val globalPortIdOption =
VFSURIFactory.decodeURI(storageUri.get).globalPortId
- val opStorage =
DocumentFactory.openDocument(storageUri.get)._1
-
- allTableStats(opId.id) = opStorage.getTableStatistics
- WorkflowExecutionsResource.updateResultSize(
- executionId,
- globalPortIdOption.get,
- opStorage.getTotalFileSize
- )
-
WorkflowExecutionsResource.updateRuntimeStatsSize(executionId)
-
WorkflowExecutionsResource.updateConsoleMessageSize(executionId, opId)
- }
+ // SINGLE_SNAPSHOT is used for HTML content, which is not a table
+ if (outputMode != OutputMode.SINGLE_SNAPSHOT) {
+ WorkflowExecutionsResource
+ .getResultUriByLogicalPortId(executionId, opId, portId)
+ .foreach { storageUri =>
+ val opStorage = DocumentFactory.openDocument(storageUri)._1
Review Comment:
Nit: For a table output port, the result update helper just above already
queries the port's storage URI and opens its document, and this block runs the
same database lookup and opens the document a second time. Could we open the
port's storage document once per changed port and reuse it for the result
update, table statistics, and result size update?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]