Skip to content

Retire the hand MeosThread guard for JMEOS's generated ensureReady - #44

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:retire/spark-meosthread-hand-guard
Jul 23, 2026
Merged

Retire the hand MeosThread guard for JMEOS's generated ensureReady#44
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:retire/spark-meosthread-hand-guard

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

JMEOS generates the per-thread MEOS-init guard: FunctionsGenerator emits GeneratedFunctions.ensureReady() and embeds it at the top of every _meos_ wrapper, so any GeneratedFunctions call initializes the calling thread on its own.

Every Spark UDF reaches MEOS only through GeneratedFunctions — the marshalling helpers UdfMarshal.*FromHex delegate to GeneratedFunctions.*_from_hexwkb, and MeosMemory.free uses Unsafe with no MEOS call — so the hand MeosThread guard and the generator's explicit MeosThread.ensureReady() emissions are redundant.

This stops emitting MeosThread.ensureReady() and its import, drops the now-obsolete build-failing per-thread-init invariant (JMEOS's generator owns the guard), and deletes MeosThread. The handler is JMEOS's recording MeosErrorHandler, which is non-exiting and surfaces a MEOS error as a MeosException through the wrapper's checkError().

This completes the generate-then-retire for MobilitySpark against the single-source guard shipped in JMEOS.

JMEOS now generates the per-thread MEOS-init guard: FunctionsGenerator
emits GeneratedFunctions.ensureReady() and embeds it at the top of every
_meos_ wrapper, so any GeneratedFunctions call initializes the calling
thread on its own. Every Spark UDF reaches MEOS only through
GeneratedFunctions — the marshalling helpers UdfMarshal.*FromHex delegate
to GeneratedFunctions.*_from_hexwkb, and MeosMemory.free uses Unsafe with
no MEOS call — so the hand MeosThread guard and the generator's explicit
MeosThread.ensureReady() emissions are redundant.

Stop emitting MeosThread.ensureReady() and its import, drop the now-obsolete
build-failing per-thread-init invariant (JMEOS's generator owns the guard),
and delete MeosThread. The handler is JMEOS's recording MeosErrorHandler,
which is non-exiting and surfaces a MEOS error as a MeosException through
the wrapper's checkError().
@estebanzimanyi
estebanzimanyi force-pushed the retire/spark-meosthread-hand-guard branch from 4430f88 to 1c16832 Compare July 23, 2026 06:45
@estebanzimanyi
estebanzimanyi merged commit 9d82a4a into MobilityDB:main Jul 23, 2026
1 check passed
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