Skip to content

Add Rust bindings for partition routing hooks - #40

Merged
adsharma merged 1 commit into
mainfrom
feat/partition-routing-hooks
Sep 20, 2026
Merged

adsharma merged 1 commit into
mainfrom
feat/partition-routing-hooks

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Exposes the engine's distributed partition-routing hooks (LadybugDB/ladybug#829) to Rust.

What

  • include/lbug_partition_routing.h + src/lbug_partition_routing.cpp: C-ABI shim over common::PartitionRoutingHooks. Point writes materialize into a per-parent row store (bulk writes fan out row-at-a-time); one scan TableFunction per parent serves the store back, so install + insert + read is a complete remote loop with no further machinery. All claimed partitions of a parent share one scan function, which the engine requires to collapse the parent scan (divergent scans read as a local/remote mix and are rejected). lookupRow stays unset (engine default: MERGE over claimed partitions errors).
  • src/partition_routing.rs: safe API — RoutingGuard::install (process-global, before opening any Database), placement/lifecycle/write callbacks with decoded Value rows, register_parent_schema for scan serving. Callbacks must be Send + Sync, must not panic (aborts rather than corrupting engine state); uninstall requires no live Databases.
  • build.rs: the shim needs full engine headers (common/partition_routing_hook.h), which prebuilt archives do not ship. Reuses a sibling ladybug checkout when present (mirrors LBUG_SOURCE_DIR's ../ladybug default; CI checks it out there) plus generated headers from its build tree, and compiles the module out otherwise.

Tests

New mock-wrapper round-trip test (mirrors the engine's partition_routing_test.cpp): claims every partition of a HASH table remote, covers point + COPY writes, parent-union reads through the bundled scan, lifecycle create/drop counts. Full suite green (159 + 3), fmt clean, no new clippy lints.

Known engine gap (not this PR)

Claiming a LIST partition is broken engine-side as of 0.20: dynamic LIST creation throws raw unordered_map::at instead of routing remotely (the HASH path returns a null table and branches to insertRow; see getOrCreatePartitionLocked). The test therefore exercises HASH; LIST works unclaimed (local) as before.

@adsharma
adsharma force-pushed the feat/partition-routing-hooks branch from 715d052 to 5cbf81c Compare September 20, 2026 14:21
Expose the engine's distributed partition-routing hooks (locate, lifecycle, insertRow/insertChunk, bindScan) through a C-ABI shim plus a safe RoutingGuard API. Writes to claimed partitions land in a bundled row store served back by a per-parent scan function, so install + insert + read forms a complete remote loop. lookupRow stays unset (engine default). The shim compiles against the amalgamated lbug.hpp alone, so no source checkout is needed; the module is always built and requires headers carrying the hooks (prebuilt archives since ladybug #1005). Includes a mock-wrapper round-trip test (point + COPY writes, parent scan, lifecycle, drop).
@adsharma
adsharma force-pushed the feat/partition-routing-hooks branch from 5cbf81c to b148501 Compare September 20, 2026 16:05
@adsharma
adsharma force-pushed the feat/partition-routing-hooks branch from f2771b2 to b148501 Compare September 20, 2026 19:41
@adsharma
adsharma merged commit e77dabd into main Sep 20, 2026
1 of 3 checks passed
@adsharma
adsharma deleted the feat/partition-routing-hooks branch September 20, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant