Skip to content

JMEOS 1.3#9

Open
JashanReel wants to merge 113 commits intoMobilityDB:mainfrom
JashanReel:fix-tests-using-docker
Open

JMEOS 1.3#9
JashanReel wants to merge 113 commits intoMobilityDB:mainfrom
JashanReel:fix-tests-using-docker

Conversation

@JashanReel
Copy link
Copy Markdown
Collaborator

JMEOS update: MEOS 1.3 compatibility, unit tests, examples, exception system

Overview

This PR brings JMEOS up to date with MEOS 1.3, fixes the entire unit test suite, adds a comprehensive set of usage examples and Jupyter notebooks, and introduces a structured Java exception system modelled after PyMEOS-CFFI.

1. MEOS 1.3 compatibility

FunctionsExtractor & FunctionsGenerator

  • Updated both tools to support multiple header files simultaneously (meos.h + meos_geo.h), making it possible to include additional headers in the future (e.g. meos_cbuffer.h)
  • Added recognition of new types introduced in MEOS 1.3
  • Regenerated functions.java from the updated headers

NewFunctionsGenerator

  • Alternative to FunctionsExtractor & FunctionsGenerator
  • Uses the json file created by the Json functions generator
  • Generates functions.java from meos-idl.json

Renamed / removed functions

  • Updated all Java classes using the 50+ functions that were renamed between MEOS 1.1 and 1.3: e.g. the tpoint_*tgeo_* pattern

Dockerfile

  • Fixed outdated branch reference and deprecated instructions

2. Unit test suite

  • Fixed all failing test classes: TFloatTest, TIntTest, TTextTest, TBoolTest, STBoxTest, TBoxTest, FloatSetTest, FloatSpanTest, FloatSpanSetTest, IntSetTest, IntSpanTest, IntSpanSetTest, TextSetTest, DateSetTest, DateSpanTest, DateSpanSetTest, TsTzSetTest, TsTzSpanTest, TsTzSpanSetTest, TGeomPointTest, TGeogPointTest
  • Corrections cover: renamed/removed function calls, assertion logic where operation semantics changed, and syntax errors
  • Added TestLogger, a JUnit 5 extension implementing BeforeEachCallback / AfterEachCallback that logs each test's name, input parameters to better trace the source error
  • All tests should pass against MEOS 1.3.

3. Usage examples & Jupyter notebooks

20+ example programs ported from the MEOS C examples:

Java file Original C file
N01_Hello_World.java 01_hello_world.c
N01_Hello_World_Geodetic.java 01_hello_world_geodetic.c
N02_AIS_Read.java 02_ais_read.c
N03_AIS_Assemble.java 03_ais_assemble.c
N03_BerlinMOD_Assemble.java 03_berlinmod_assemble.c
N04_AIS_Store.java 04_ais_store.c
N04_AIS_Stream_DB.java 04_ais_stream_db.c
N04_AIS_Stream_File.java 04_ais_stream_file.c
N05_BerlinMOD_Disassemble.java 05_berlinmod_disassemble.c
N06_BerlinMOD_Clip.java 06_berlinmod_clip.c
N07_BerlinMOD_Tile.java 07_berlinmod_tile.c
N08_BerlinMOD_Simplify.java 08_berlinmod_simplify.c
N09_BerlinMOD_Aggregate.java 09_berlinmod_aggregate.c
N10_AIS_Assemble_Full.java ais_assemble_full.c
N11_AIS_Expand_Full.java ais_expand_full.c
N12_AIS_Transform_Full.java ais_transform_full.c
N13_Aggregation_Demo.java *_agg.c files
N14_RTree_Index.java rtree_example.c
N15_TPoint_MakeCoords.java tpointseq_make_coords.c
N16_Clustering_KMeans.java popplaces_kmeans.c
N17_Clustering_Regions_Intersecting.java regions_intersecting.c
N18_Clustering_DBSCAN.java geonames_dbscan.c

Two interactive Jupyter notebooks using the IJava kernel, allowing in-notebook execution of JMEOS code with inline results:

  • Jupyter_AIS.ipynb: exercices exploring AIS data
  • Jupyter_BerlinMod_Brussels.ipynb: RTree vs Brute Force on the Brussels communes dataset

4. Java exception system

Previously, errors raised by the native MEOS library were printed to the console only and there was no way to intercept them in Java via try-catch, making robust error handling impossible in any application built on JMEOS.

The new system, modelled after PyMEOS-CFFI, consists of three components:

Exception hierarchy

20 classes organised into 4 branches:

Branch Codes Description Subclasses
MeosInternalError 1–8 Internal MEOS errors: type, memory allocation, aggregation, file and directory errors 7
MeosArgumentError 10–12 Invalid argument errors: argument type, argument value, null argument 3
MeosIoError 20–27 I/O errors during parsing or serialisation of MF-JSON, WKT, WKB, GeoJSON 8
MeosFeatureNotSupported 13 Operations not implemented in the current MEOS version 1

MeosErrorHandler

Registers a C callback via the error_handler_fn interface. On each native call, it captures the error code and message. checkError() maps the code to the appropriate Java exception and throws it.

Integration in functions.java

Every generated wrapper function now calls MeosErrorHandler.checkError() immediately after the native call to ensure no MEOS error can remain silent.

62727 and others added 30 commits February 5, 2026 12:11
…o run them & added .idea personal config files in the .gitignore
…n of temporal_to_tsequence (temporal.c) which was still given a string as the interpolation type instead of an integer & added TestLogger in order to trace the lifecycle of each test and the parameters used
…tInst has no interpolation but it used to be tested as a LINEAR one
…y geom_in, pgis_geography_in by geog_in, adapted ConversionUtils & TPoint files accordingly
…point_as_text now tspatial_as_text, tpoint_to_stbox now tspatial_to_stbox, tpoint_srid now tspatial_srid: tpoint_round, tpoint_start_value, tpoint_end_value left
… with a single instance or a discret sequence set of TGeogPoint/TGeomPoint, fixed assertion using a STEP print verification (Interp=Step
- Replace meos.h with v1.3 and add meos_geo.h
- Update FunctionsExtractor and Generator to support new headers and types
- Fix existing tests to match MEOS
…into java + the resulting generated csv files
@JashanReel JashanReel changed the title Fix tests using docker JMEOS 1.3 May 2, 2026
@estebanzimanyi
Copy link
Copy Markdown
Member

This PR is directly referenced in MobilityDB Discussion #861 — a new cross-platform SQL portability initiative targeting MobilityDB/PostgreSQL, MobilityDuck/DuckDB, and MobilitySpark/Spark.

JMEOS 1.3's NewFunctionsGenerator is the key mechanism for Phase 3 of that plan: auto-generating Spark UDF registrations for all MEOS functions from the meos-api.json catalog. Once this PR merges, extending the generator to emit Spark UDF registration code (in addition to JMEOS wrappers) is the next concrete step.

The discussion includes a portable operator → function mapping table that defines the canonical SQL name every platform should register for each MEOS function — feedback on the names from the JMEOS perspective would be valuable.

cc @JashanReel @nmareghn @mauxnier @1-ARIjitS

@Davichet-e
Copy link
Copy Markdown
Member

Likely outside of the scope of this PR, but have you given a thought to use jextract and Panama over the current JNI + custom code? Maybe we could greatly simplify the project. We would need java 22+ though, which shouldn't be an issue since last LTS is 25.

run: pwd

- name: Update apt cache
run: sudo apt-get update
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really needed? Seems images should be quite up to date..

Comment thread src/lib/meos_geo.h Outdated
@@ -0,0 +1,901 @@
/*****************************************************************************
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those files still needed if we start to solely rely on the JSON generator?

Comment thread src/main/java/builder/resources/meos.h Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for the files in lib, are those still needed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code generation process should probably not be part of the main folder, I propose to create a new top-level folder called codegen in which we would have:

  • src/ containing generator code
    • test (test the generator in itself)
    • main
  • input/ with the json file from MEOS API

Also, add a prefix to generated files (only functions.java) => GeneratedFunctions.java (also CamelCase)

README.MD should then be updated to explain how to use the new structure to update the generated code.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, Examples folder should live at the root of the project.



import static org.junit.jupiter.api.Assertions.*;

@ExtendWith(TestLogger.class)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with junit logger config and delete TestLogger.java

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


public class MeosErrorHandler implements error_handler_fn {

private static final Logger logger = LoggerFactory.getLogger(MeosErrorHandler.class);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a Generic exception in case error code is not known.

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.

4 participants