Skip to content

feat(wirings): Kafka Streams DSL tier wirings + capstone demo (stacks on #3; Kafka mirror of Flink #6→#10) - #4

Closed
estebanzimanyi wants to merge 2 commits into
MobilityDB:codegen/kafka-meos-opsfrom
estebanzimanyi:feat/kafka-tier-wirings
Closed

feat(wirings): Kafka Streams DSL tier wirings + capstone demo (stacks on #3; Kafka mirror of Flink #6→#10)#4
estebanzimanyi wants to merge 2 commits into
MobilityDB:codegen/kafka-meos-opsfrom
estebanzimanyi:feat/kafka-tier-wirings

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Kafka-side mirror of the MobilityFlink wirings stack (PRs #6#10). Single PR with all four tier wirings + runnable composite demo, since Kafka Streams' DSL is naturally lambda-driven and most tier wirings collapse to small static-factory classes returning serializable functional-interface implementations.

Stacks on PR #3 (the Kafka codegen mirror). Additive-only — no existing file touched.

What's in this PR (6 new files under kafka-streams-app/src/main/java/org/mobilitydb/kafka/meos/wirings/)

Tier Wiring class Pattern
stateless (804 methods) MeosStatelessOps static factory: predicate(...) / intPredicate(...) / mapper(...)Predicate<K,V> / ValueMapper<V,R> for KStream.filter / .mapValues
bounded-state (797 methods) MeosBoundedStateProcessor full Processor<KIn,VIn,KOut,VOut> class with KeyValueStore<KIn,byte[]> for per-key MEOS-handle state that survives changelog replay / rebalance
windowed (161 methods) MeosWindowedAggregator static factory: initializer(...) / aggregator(...) for KStream.groupByKey().windowedBy(...).aggregate(...)
cross-stream (140 methods) MeosCrossStreamJoiner static factory: joiner(...) wrapping serializable ValueJoiner for KStream.join(other, joiner, JoinWindows), same-key pairing, time-bounded match window
io-meta (195 methods) covered by MeosStatelessOps.mapper(...) (no state, no window)
sequence-only (14 methods) inherently non-streamable, no wiring

Plus:

  • MeosOpsRuntime.java — wirings-package alias for the codegen package's MEOS_AVAILABLE flag
  • demo/MeosWiringsDemoTopology.java — runnable Kafka Streams topology composing all 4 tier wirings; uses TopologyTestDriver (no broker required)
  • README.md — full tier vocabulary, lambda-first design rationale, demo walkthrough, coexistence with berlinmod.MEOSBridge

Cumulative wirings coverage: 2,097 of 2,097 emitted methods (100%) wirable through 5 generic classes; zero per-method registration. Identical to Flink side.

Design choice — lambda-first

Kafka Streams' DSL accepts lambdas directly (Predicate, ValueMapper, Aggregator, ValueJoiner). Only bounded-state needs a real class for state-store binding via Processor.init(ProcessorContext). The wirings reflect that asymmetry — small static-factory classes for the four lambda-shaped tiers, one full Processor class for bounded-state.

Adopters wanting a class-shaped wiring (matching Flink for cross-binding parity) can subclass any of the helpers — the serializable functional interfaces are public.

State-store discipline (bounded-state)

Same as the Flink wirings: raw jnr.ffi.Pointer does not survive Kafka Streams' changelog-replay / rebalance / state-rebuild paths (the state-store changelog is a Kafka topic; state must be byte-serializable to be replayable). MeosBoundedStateProcessor stores state as byte[] (typically MEOS-WKB or MEOS-WKT) with three adopter-supplied lambdas mediating the round-trip:

byte[] state               -- per-key serialized MEOS value (in changelog-backed KeyValueStore)
    ↓ deserialize (bytes → Pointer)
Pointer prev               -- in-flight MEOS handle
    ↓ step(prev, record) → (newPointer, output record)
Pointer next, Record       -- new in-flight handle + optional forward
    ↓ serialize (Pointer → bytes)
byte[] newState            -- back to KeyValueStore

First record for a key sees prior == null (no prior state); wiring skips deserialize and lets step seed.

End-to-end demo

MeosWiringsDemoTopology composes all four tier wirings into one Kafka Streams topology:

  1. vehicle-events source → 2. stateless filter → 3. bounded-state processor (per-region running tbox union) → 4. windowed aggregator (30s tumbling) → 5. cross-stream joiner (±1m bound, joined against region-queries topic) → 6. overlap-output sink.

Run via mvn exec:java. main() always prints Topology.describe(); when MEOS available, instantiates TopologyTestDriver (no broker required).

Compile verification

Locally green: 110 .class files total (94 from PR #3 base + 16 new — 4 wiring classes + 11 nested lambda interfaces + MeosOpsRuntime + 1 demo class).

Stacking

Stacks on codegen/kafka-meos-ops (PR #3). Whole 11-file diff is contained under kafka-streams-app/src/main/java/org/mobilitydb/kafka/meos/wirings/.

… surface (Kafka mirror of MobilityFlink MobilityDB#5)

Mirror of MobilityFlink codegen/flink-meos-ops (PR MobilityDB#5) for the Kafka
Streams binding. Same generators, same tier classification, same
catalog source — differs only in package path
(`org.mobilitydb.kafka.meos`) and module layout (`kafka-streams-app/`
vs `flink-processor/`).

Adds 50 `MeosOps<Class>` + 6 `MeosOpsFree<Header>` + 1 shared
`MeosOpsRuntime` = 57 Java classes, 2,097 methods (77.7% of JMEOS
PR MobilityDB#19's 2,699-method surface).

Stacks on feat/jmeos-bridge-swap; additive-only; touches no existing
file. See MobilityFlink MobilityDB#5 for the full tier vocabulary, regeneration
recipe, and coexistence design with `berlinmod.MEOSBridge`.
…facades + capstone demo

Adds the org.mobilitydb.kafka.meos.wirings package — Kafka mirror of
the MobilityFlink wirings (PRs MobilityDB#6MobilityDB#10). Single PR with all four tiers
+ runnable composite demo, since Kafka Streams' DSL is naturally
lambda-driven and most tier wirings collapse to small static-factory
classes returning serializable functional-interface implementations.

## Files

- MeosStatelessOps.java — predicate/intPredicate/mapper factories
  returning Predicate<K,V> / ValueMapper<V,R> for KStream.filter /
  .mapValues (covers stateless tier: 804 methods + io-meta: 195
  methods)
- MeosBoundedStateProcessor.java — full Processor<KIn,VIn,KOut,VOut>
  class with KeyValueStore<KIn,byte[]> for per-key MEOS-handle state
  that survives changelog replay / rebalance (covers bounded-state
  tier: 797 methods)
- MeosWindowedAggregator.java — initializer/aggregator factories for
  KStream.groupByKey().windowedBy(...).aggregate(...) (covers
  windowed tier: 161 methods)
- MeosCrossStreamJoiner.java — joiner factory wrapping a serializable
  ValueJoiner for KStream.join(other, joiner, JoinWindows) (covers
  cross-stream tier: 140 methods)
- MeosOpsRuntime.java — wirings-package alias for the codegen package's
  MeosOpsRuntime.MEOS_AVAILABLE flag (libmeos probed once per JVM)
- demo/MeosWiringsDemoTopology.java — runnable Kafka Streams topology
  composing all four tier wirings into one pipeline (per-region
  running-union → 30s tumbling aggregate → ±1m cross-stream join
  against region-queries); main() prints topology description always,
  instantiates TopologyTestDriver when MEOS_AVAILABLE (no broker
  required)
- README.md — tier vocabulary, lambda-first design rationale, full
  recipe + demo walkthrough, coexistence with berlinmod.MEOSBridge

## Cumulative wirings-layer coverage

Same as the Flink side: 2,097 of 2,097 emitted methods (100%)
wirable through 5 generic classes; zero per-method registration.

## Design choice — lambda-first

Kafka Streams' DSL accepts lambdas directly (Predicate, ValueMapper,
Aggregator, ValueJoiner). Only bounded-state needs a real class for
state-store binding via Processor.init(ProcessorContext). The wirings
reflect that asymmetry: small static-factory classes for the four
lambda-shaped tiers, one full Processor class for bounded-state.
Adopters wanting a class-shaped wiring (matching Flink for
cross-binding parity) can subclass any of the helpers — the
serializable functional interfaces are public.

## Stacks on PR MobilityDB#3 (codegen mirror)

Additive-only: 6 new files under
kafka-streams-app/src/main/java/org/mobilitydb/kafka/meos/wirings/.
Touches no existing file. Locally compile-verified: 110 .class files
total (94 from PR MobilityDB#3 base + 16 new — 4 wiring classes + 11 nested
lambda interfaces + MeosOpsRuntime + 1 demo class).
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Consolidated into #13 (consolidate/kafka-streaming-implementation).

@estebanzimanyi
estebanzimanyi changed the base branch from main to codegen/kafka-meos-ops June 11, 2026 16:44
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Superseded by the Path-B consolidation: the former 12-deep stack is collapsed into three reviewable topical PRs — scaffold #1 → MEOS integration #14 → benchmark #15 — each one clean squashed commit with the generated-facade bulk, dead family-flag profiles, and invented synthetic corpus removed. Closing as folded into #14/#15.

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