Skip to content

Split the monolithic MeosLibrary JNR-FFI interface into four sub-interfaces#17

Closed
estebanzimanyi wants to merge 2 commits into
MobilityDB:mainfrom
estebanzimanyi:fix/split-meoslibrary-4way
Closed

Split the monolithic MeosLibrary JNR-FFI interface into four sub-interfaces#17
estebanzimanyi wants to merge 2 commits into
MobilityDB:mainfrom
estebanzimanyi:fix/split-meoslibrary-4way

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

The single MeosLibrary interface binds the entire MEOS surface, so the JVM builds one dynamic proxy whose static initializer exceeds the 64 KB method bytecode limit and throws MethodTooLargeException on ARM64, macOS and Windows once the binding set grows large. This partitions the surface into four public-static sub-interfaces MeosLibraryPart0..3, each loaded independently against the same native libmeos so each generated proxy stays well under the limit. The sub-interfaces are public static rather than private because JNR-FFI's AsmClassLoader runs in a different classloader and raises IllegalAccessError: cannot access superinterface for private nested ones. The partition is a deterministic slice of the sorted unique function names into balanced contiguous buckets (part = floor(i * 4 / total)), so overloads of a name share a part and re-running the generator reproduces the same assignment. Every public static wrapper in functions keeps its exact name and signature; only its internal dispatch changes from MeosLibrary.meos.x to MeosLibraryPartK.meos.x, so consumers compile unchanged. The same partition is implemented in FunctionsGenerator so a future regen reproduces the split.

…rfaces

The single MeosLibrary interface binds the entire MEOS surface, so the
JVM builds one dynamic proxy whose static initializer exceeds the 64 KB
method bytecode limit and throws MethodTooLargeException on ARM64, macOS
and Windows once the binding set grows large. Partition the surface into
four public-static sub-interfaces MeosLibraryPart0..3, each loaded
independently against the same native libmeos so each generated proxy
stays well under the limit. The sub-interfaces are public static rather
than private because JNR-FFI's AsmClassLoader runs in a different
classloader and raises IllegalAccessError: cannot access superinterface
for private nested ones. The partition is a deterministic slice of the
sorted unique function names into balanced contiguous buckets
(part = floor(i * 4 / total)), so overloads of a name share a part and
re-running the generator reproduces the same assignment. Every public
static wrapper in functions keeps its exact name and signature; only its
internal dispatch changes from MeosLibrary.meos.x to
MeosLibraryPartK.meos.x, so consumers compile unchanged. The same
partition is implemented in FunctionsGenerator so a future regen
reproduces the split.
MobilityDB CMakeLists added find_package(GSL REQUIRED) for skiplists, so
the CI step that builds MEOS from MobilityDB source now fails at cmake
configure (Could NOT find GSL) before any JMEOS code is compiled. This
breaks main and every pull request identically. Provision libgsl-dev
alongside the other MEOS build dependencies so the native library builds
and the Java surface is actually exercised.
@estebanzimanyi
Copy link
Copy Markdown
Member Author

CONFL diagnosis: Same as #15/#16. PR #9 (merged) moved FunctionsGenerator.java from src/main/java/builder/ to codegen/src/main/java/. This 4-file PR's split-interface refactor needs the new layout.

Path forward: re-target the touched files to the post-#9 layout. The PR's intent (split MeosLibrary into 4 sub-interfaces) is sound; the structural change happens in the new jmeos-core/src/main/java/functions/ location now. Haversine + PointToSegment wrappers requested by stream consumers (per the cross-repo handoff) already ship in #18 (utils.spatial.*); this PR's sub-interface split is the orthogonal architectural improvement.

@estebanzimanyi
Copy link
Copy Markdown
Member Author

Superseded by #19. PR #19's regenerated GeneratedFunctions.java splits the JNR-FFI surface into 4 sub-interfaces (MeosLibraryPartA / PartB / PartC / PartD) automatically — same outcome as this PR's intent. The structural-rebase friction this PR's pre-multi-module src/main/java/builder/ paths surfaced is sidestepped by the codegen-driven path that consumes codegen/input/meos-idl.json.

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