Skip to content

feat: JMEOS 1.3 + BerlinMOD portable SQL + binary roundtrip protocol#4

Open
estebanzimanyi wants to merge 1 commit intoMobilityDB:mainfrom
estebanzimanyi:feat/jmeos-1.3-berlinmod-poc
Open

feat: JMEOS 1.3 + BerlinMOD portable SQL + binary roundtrip protocol#4
estebanzimanyi wants to merge 1 commit intoMobilityDB:mainfrom
estebanzimanyi:feat/jmeos-1.3-berlinmod-poc

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

@estebanzimanyi estebanzimanyi commented May 6, 2026

Summary

  • JMEOS 1.3 wired as the MEOS layer for MobilitySpark, exposing five Spark SQL UDFs: atTime, eIntersects, nearestApproachDistance, eDwithin, tgeompoint (WKT→hex-WKB), geomFromText
  • BerlinMOD Q1/Q3/Q4/Q5/Q6 in the RFC #861 portable SQL dialect — same .sql files run unchanged on MobilityDB (PostgreSQL), MobilityDuck (DuckDB), and MobilitySpark (Apache Spark)
  • Binary roundtrip protocol: ashexewkb(val) UDF serialises temporal values to MEOS hex-WKB — the same C function (temporal_as_hexwkb, variant 0, NDR) called by MobilityDB/MobilityDuck. Text in (WKT CSV), binary out (hex-WKB), byte-level equality tested across all three platforms
  • Q3 now fully comparable — previously skipped because output format differed; ashexewkb(atTime(trip, instant)) produces identical bytes on all three platforms
  • QRT query — new pure roundtrip query: all trips serialised to hex-WKB; expected/qrt.csv generated from MobilityDB as ground truth; byte equality confirmed
  • Shared cross-platform test infrastructure in berlinmod/: dataset CSV files, expected/ for Q1/Q3/Q4/Q5/Q6/QRT, run_mbdb.sh (MobilityDB, locally verified 6/6 PASS), run_mduck.sh (MobilityDuck runner)
  • CI: install libmeos runtime deps + extract libmeos.so from JMEOS jar, set LD_LIBRARY_PATH; 15 unit tests pass
  • Geometry stored as WKT text (not hex-EWKB) — portable across all platforms that accept geo_from_text()

Byte-equality claim

The key correctness property: JMEOS calls temporal_as_hexwkb(ptr, 0) (MEOS C function); MobilityDB SQL calls ashexewkb(tgeompoint) (same C function). The asHexEWKB_matches_mbdb_expected unit test asserts byte-for-byte equality against the known MobilityDB output for trip 1.

Test plan

  • 15 Java unit tests pass on CI (including 3 new asHexEWKB tests)
  • run_mbdb.sh: Q1/Q3/Q4/Q5/Q6 + QRT — 6/6 PASS against expected/ on MobilityDB locally
  • run_mduck.sh: Q1/Q3/Q4/Q5/Q6 + QRT — needs MobilityDuck CLI to verify
  • spark-submit BerlinMODDemo berlinmod/data berlinmod/expected — needs Spark environment

🤖 Generated with Claude Code

@estebanzimanyi estebanzimanyi force-pushed the feat/jmeos-1.3-berlinmod-poc branch 4 times, most recently from eec0530 to 2566ffc Compare May 6, 2026 16:55
@estebanzimanyi estebanzimanyi changed the title feat: wire JMEOS 1.3 + BerlinMOD Q1/Q3/Q4/Q5/Q6 portable SQL POC feat: JMEOS 1.3 + BerlinMOD portable SQL + binary roundtrip protocol May 6, 2026
@estebanzimanyi estebanzimanyi force-pushed the feat/jmeos-1.3-berlinmod-poc branch 5 times, most recently from b338693 to c07a2af Compare May 6, 2026 20:14
…uck/MobilitySpark

Extends the BerlinMOD cross-platform POC (RFC #861 portable dialect) from 6
queries to 9 (Q1–Q8 + QRT), adding the full temporal-restriction, trajectory,
and region-intersection query set.

New queries:
  Q2  eIntersects(trip, region)  — region intersection filter
  Q7  atTime(trip, tstzspan)     — period restriction (binary output via asHexWKB)
  Q8  trajectory(trip)           — spatial path as hex WKB geometry
  QRT already existed; Q3/Q7 confirmed byte-identical cross-platform

API corrections:
  - Remove atPeriod alias (old pre-1.0 name); Q7 uses atTime(trip, tstzspan)
  - atTime UDF is now a unified (String, String) dispatcher:
      "[…]" prefix → tstzspan_in + temporal_at_tstzspan (Q7 period path)
      otherwise    → pg_timestamptz_in + temporal_at_timestamptz (Q3 instant path,
                     Spark implicitly casts TIMESTAMP column → STRING)
  - trajectory UDF returns geo_as_hexewkb (not geo_as_ewkt) so the geometry
    binary matches PostgreSQL COPY and DuckDB COPY output byte-for-byte

New UDFs (TemporalUDFs):
  startTimestamp, endTimestamp, numInstants, speed, atGeometry

New UDFs (GeoUDFs):
  eContains, trajectory (hex-WKB)

New data files:
  berlinmod/data/query_regions.csv  — polygon region for Q2
  berlinmod/data/query_periods.csv  — tstzspan period for Q7

New runner:
  berlinmod/run_mspark.sh  — three-runner story complete

All 9 queries verified ALL PASS on MobilityDB (run_mbdb.sh).
@estebanzimanyi estebanzimanyi force-pushed the feat/jmeos-1.3-berlinmod-poc branch from c07a2af to b17c0a4 Compare May 7, 2026 07:22
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