Skip to content

Refactor backend ports in compiler - #2299

Merged
Yicong-Huang merged 47 commits into
masterfrom
yicong-refactor-port
Jan 20, 2024
Merged

Yicong-Huang merged 47 commits into
masterfrom
yicong-refactor-port

Conversation

@Yicong-Huang

@Yicong-Huang Yicong-Huang commented Jan 18, 2024 •

Copy link
Copy Markdown
Contributor

This PR refactors the ports on the backend.

PortIdentity

Previously, we store ports in a list and used the index to refer to a port. This is not useful when the ports are mapped from logical operator to physical operator (the exact sequence of the ports may change), or when supporting dynamic ports (removing a port would cause the index change).

Now we introduce PortIdentity as the id of a port. The same port and identity will be used across logical, physical, and in workers.

The exact structure of PortIdentity is shown below (generated by protobuf):

final case class PortIdentity(
    id: Int = 0,
    internal: Boolean = false
)

A PortIdentity has a field for indicating internal or not. This is to differentiate internal ports and external ports. Internal ports are ports that are added between the physical operators of a logical operator. External ports are those set on the logical operator and link to other ports from other logical operators.

New InputPort and OutputPort

The InputPort has been updated (generated by protobuf):

final case class InputPort(
    id: PortIdentity = PortIdentity(),
    displayName: String = "",
    allowMultiLinks: Boolean = false,
    dependencies: Seq[PortIdentity] = Seq.empty
 )

Notably, we moved dependencies from the PhysicalOp into InputPort. It is now a sequence of PortIdentities which denotes the ports that this port is depending on.

The OutputPort has minor changes and we will adding the blocking property into it in the future.

LogicalLink and PhysicalLink

Both links are updated to use PortIdentities instead of port index (Int) accordingly:

case class LogicalLink(
    @JsonProperty("fromOpId") fromOpId: OperatorIdentity,
    fromPortId: PortIdentity,
    @JsonProperty("toOpId") toOpId: OperatorIdentity,
    toPortId: PortIdentity
)
final case class PhysicalLink(
    fromOpId: PhysicalOpIdentity,
    fromPortId: PortIdentity,
    toOpId: PhysicalOpIdentity,
    toPortId: PortIdentity,
)

Frontend ports plan

For now, we add some adapt functions to help hookup with the new backend design, and fully supports backward compatibility.

Future plan:

  • The frontend has other redundant definitions such as PortDescription and PortProperty which can be further merged and refactored.
  • Also, we need to hookup dynamic port with the new backend.

In-worker ports plan

Workers (both Python and Java) are using ports as well. Right now they are still using port index, or PortOrdinal. We plan to unify them in the future as well.

# Conflicts:
#	core/amber/src/main/protobuf/edu/uci/ics/amber/engine/common/virtualidentity.proto
#	core/amber/src/main/protobuf/edu/uci/ics/amber/engine/common/workflow.proto
#	core/amber/src/main/python/proto/edu/uci/ics/amber/engine/common/__init__.py
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/controller/promisehandlers/SkewDetectionHandler.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/deploysemantics/PhysicalOp.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/messaginglayer/OutputManager.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/scheduling/ExpansionGreedyRegionPlanGenerator.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/scheduling/WorkflowScheduler.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/scheduling/resourcePolicies/ResourceAllocator.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/worker/DataProcessor.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/worker/EpochManager.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/worker/UpstreamLinkStatus.scala
#	core/amber/src/main/scala/edu/uci/ics/amber/engine/architecture/worker/promisehandlers/StartHandler.scala
#	core/amber/src/main/scala/edu/uci/ics/texera/workflow/common/operators/aggregate/AggregateOpDesc.scala
#	core/amber/src/main/scala/edu/uci/ics/texera/workflow/common/workflow/PhysicalPlan.scala
#	core/amber/src/main/scala/edu/uci/ics/texera/workflow/operators/visualization/wordCloud/WordCloudOpDesc.java
#	core/amber/src/main/scalapb/edu/uci/ics/amber/engine/common/virtualidentity/VirtualidentityProto.scala
#	core/amber/src/main/scalapb/edu/uci/ics/amber/engine/common/workflow/PhysicalLink.scala
#	core/amber/src/main/scalapb/edu/uci/ics/amber/engine/common/workflow/WorkflowProto.scala
#	core/amber/src/test/scala/edu/uci/ics/amber/engine/architecture/worker/WorkerSpec.scala
@Yicong-Huang
Yicong-Huang merged commit 6cadd8f into master Jan 20, 2024
@Yicong-Huang
Yicong-Huang deleted the yicong-refactor-port branch January 20, 2024 18:49
Yicong-Huang added a commit that referenced this pull request Jan 23, 2024
This PR adds back the missed ports in Java-based operators due to
refactoring in #2299.
Yicong-Huang added a commit that referenced this pull request Jan 23, 2024
This PR fixes 
1. the missed ports of scala operators, caused by #2299 
2. the `allowMultiLinks` parameter is mismatched on the frontend.
Yicong-Huang added a commit that referenced this pull request Feb 13, 2024
This PR fixes an issue caused by #2299, where the dynamic ports cannot
be saved properly between workflow reloads.
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
This PR refactors the ports on the backend.

### PortIdentity
Previously, we store ports in a list and used the index to refer to a
port. This is not useful when the ports are mapped from logical operator
to physical operator (the exact sequence of the ports may change), or
when supporting dynamic ports (removing a port would cause the index
change).

Now we introduce `PortIdentity` as the id of a port. The same port and
identity will be used across logical, physical, and in workers.

The exact structure of PortIdentity is shown below (generated by
protobuf):
``` 
final case class PortIdentity(
    id: Int = 0,
    internal: Boolean = false
)
```
A PortIdentity has a field for indicating `internal` or not. This is to
differentiate internal ports and external ports. Internal ports are
ports that are added between the physical operators of a logical
operator. External ports are those set on the logical operator and link
to other ports from other logical operators.

### New InputPort and OutputPort
The `InputPort` has been updated (generated by protobuf):
```
final case class InputPort(
    id: PortIdentity = PortIdentity(),
    displayName: String = "",
    allowMultiLinks: Boolean = false,
    dependencies: Seq[PortIdentity] = Seq.empty
 )
```
Notably, we moved `dependencies` from the PhysicalOp into InputPort. It
is now a sequence of PortIdentities which denotes the ports that this
port is depending on.

The `OutputPort` has minor changes and we will adding the `blocking`
property into it in the future.

### LogicalLink and PhysicalLink
Both links are updated to use PortIdentities instead of port index (Int)
accordingly:
```
case class LogicalLink(
    @JsonProperty("fromOpId") fromOpId: OperatorIdentity,
    fromPortId: PortIdentity,
    @JsonProperty("toOpId") toOpId: OperatorIdentity,
    toPortId: PortIdentity
)
```
```
final case class PhysicalLink(
    fromOpId: PhysicalOpIdentity,
    fromPortId: PortIdentity,
    toOpId: PhysicalOpIdentity,
    toPortId: PortIdentity,
)
```

### Frontend ports plan
For now, we add some adapt functions to help hookup with the new backend
design, and fully supports backward compatibility.
 
Future plan:
- The frontend has other redundant definitions such as `PortDescription`
and `PortProperty` which can be further merged and refactored.
- Also, we need to hookup `dynamic port` with the new backend. 

### In-worker ports plan
Workers (both Python and Java) are using ports as well. Right now they
are still using port index, or `PortOrdinal`. We plan to unify them in
the future as well.
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
This PR adds back the missed ports in Java-based operators due to
refactoring in apache#2299.
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
This PR fixes 
1. the missed ports of scala operators, caused by apache#2299 
2. the `allowMultiLinks` parameter is mismatched on the frontend.
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
This PR fixes an issue caused by apache#2299, where the dynamic ports cannot
be saved properly between workflow reloads.
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Oct 2, 2026
### What changes were proposed in this PR?

Removes three exported types from `execute-workflow.interface.ts` that
nothing imports: `InputPort`, `OutputPort` and `WebOutputMode`. **−9
lines.** There is no behaviour change: they are compile-time types with
no reference anywhere in the repo, so they never reach the built
JavaScript. `WebPaginationUpdate.mode` and `WebDataUpdate.mode` still
name their mode types directly, as before.

### History

| | |
| --- | --- |
| **Introduced by** | apache#1214 (2021-07-05), "Refactor frontend to handle
different incremental output mode": `WebOutputMode`. apache#2299 (2024-01-20),
"Refactor backend ports in compiler": `InputPort`, `OutputPort` |
| **Usage removed by** | apache#7783 (2026-08-22). It deleted
`OperatorAvailableResult`, whose `outputMode` field was the only use of
`WebOutputMode`, and left the alias behind. `InputPort` / `OutputPort`
were **never used** |

The port types have been unused for the twenty months since they were
added.

### Any related issues, documentation, discussions?

Closes apache#8818

### How was this PR tested?

No new tests; these are type-only deletions.

From `frontend/`:

- `npx ng test --watch=false`, with one `--include` for the file's own
spec plus each of the 21 specs that import it (22 files): 1412 tests
pass, 1 is skipped (an existing `it.skip` elsewhere).
- `npx tsc --noEmit -p src/tsconfig.app.json`: clean.
- `yarn format:ci`: clean.
- `npx ng build`: success.

To re-check:

```
git grep -n -w -E "InputPort|OutputPort|WebOutputMode" -- frontend ':!frontend/src/app/common/type/proto'   # no hits (the generated proto module has its own, unrelated InputPort/OutputPort)
```

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants