Repository navigation
Commit d1553b5
feat(contrib): SPI crate split + worked example contrib (PR1.7 part 1)
Substantive piece of PR1.7. Two structural changes break what was
otherwise going to be a cyclic dependency between core and contribs:
1. New crate native/contrib-spi/ (`comet-contrib-spi`):
- Defines the `ContribOperatorPlanner` trait that contribs implement.
- Owns the process-wide registry (`register_contrib_planner`,
`lookup_contrib_planner_by_kind`, `registered_contrib_kinds`).
- Light-weight `ContribError` enum for SPI errors. Core converts to
its own `ExecutionError` at the dispatch site.
- 1 unit test covering registration round-trip.
- Only deps: `datafusion` + `log`. No deps on core, no deps from
core back. The SPI is the leaf both core and contribs depend on.
2. New crate contrib/example/native/ (`comet-contrib-example`):
- rlib (NOT cdylib) -- linked INTO core's libcomet via the
`contrib-example` Cargo feature flag on core.
- Registers a `NoOpPlanner` against kind `"example-no-op"` via
`#[ctor::ctor]`. The planner returns a sentinel error so tests
can verify the full JVM->JNI->native->contrib dispatch chain.
- Depends on `comet-contrib-spi` (NOT on core).
- Real contribs follow the same shape: rlib + #[ctor] + thin
dependency on the SPI crate.
Core rewiring:
- native/core/Cargo.toml: `comet-contrib-spi` mandatory dep;
`comet-contrib-example` optional dep gated by feature
`contrib-example` (default-on so released builds ship the
example registered).
- native/core/src/lib.rs: `extern crate comet_contrib_example` gated
by the feature so #[ctor] runs at libcomet load.
- native/core/src/execution/planner/contrib.rs: now just re-exports
the SPI surface for backwards-compatible imports within core.
- native/core/src/execution/planner.rs: ContribOp dispatcher now
recursively builds native children, calls the SPI's `plan(payload,
children) -> Arc<dyn ExecutionPlan>`, wraps in `SparkPlan`. Maps
`ContribError` to `ExecutionError::GeneralError` with a clear
contrib-identified prefix.
Workspace wiring:
- native/Cargo.toml: adds `contrib-spi` to default-members so the
SPI crate is built/checked with the rest of the workspace.
- Adds `../contrib/example/native` to workspace members (NOT
default-members) so it shares the workspace lockfile and
dependency overrides but isn't compiled standalone.
Build state: `cargo check` on all three crates (core, contrib-spi,
contrib-example) is clean. SPI unit test passes. The Maven side of the
example contrib (pom.xml, Scala extension, ServiceLoader entry,
integration test) is NOT in this commit -- it lands in a follow-up
on the same branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 8b69471 commit d1553b5
10 files changed
Lines changed: 446 additions & 136 deletions
File tree
- contrib/example/native
- src
- native
- contrib-spi
- src
- core
- src
- execution
- planner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments