Skip to content

Carry a MEOS struct that is all scalars as a value - #28

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:feat/value-structs-by-value
Sep 3, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:feat/value-structs-by-value

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A struct MEOS hands over through a pointer is not always opaque. Where the
catalog states its whole layout in scalars and no class stands for it, the
address carries nothing the value does not: Interval, Match, BOX3D,
AFFINE and TimeTzADT are values, and the binding carries them as such. The
argument sites take the value and hand MEOS the address of a copy that lives
exactly as long as the call; the return sites read the value MEOS wrote and
leave the memory to MEOS, as every other value the layer reads back does. 49
methods reach the object layer that way — TsTzSpan.Duration,
Span.ShiftScale, Temporal.Tprecision, TsTzSpanSet.Bins,
Temporal.FrechetPath and their kin — 1171 methods against 1122, 124 deferred
against 171.

A value struct reads and writes itself through the text I/O the catalog names
for it, so Interval.In("1 day") goes through MEOS's own parser and
ToString() through its printer, at the decimal digits the catalog's encoding
records. Nothing about the format is stated twice.

The rule excludes a struct a class already stands for, which is what keeps
Npoint and Nsegment one type each rather than a class and a struct spelling
the same value.

Four tests read the values back: a span answers its duration as an interval of
2 days, an interval round-trips its own text and raises on text MEOS refuses, a
span shifted and scaled by two intervals given as values lands where it should,
and a Frechet path arrives as the matches themselves — in the order the kernel
walks its distance matrix, from the last pair back to the first.

A struct MEOS hands over through a pointer is not always opaque. Where the
catalog states its whole layout in scalars and no class stands for it, the
address carries nothing the value does not: `Interval`, `Match`, `BOX3D`,
`AFFINE` and `TimeTzADT` are values, and the binding carries them as such. The
argument sites take the value and hand MEOS the address of a copy that lives
exactly as long as the call; the return sites read the value MEOS wrote and
leave the memory to MEOS, as every other value the layer reads back does. 49
methods reach the object layer that way — `TsTzSpan.Duration`,
`Span.ShiftScale`, `Temporal.Tprecision`, `TsTzSpanSet.Bins`,
`Temporal.FrechetPath` and their kin — 1171 methods against 1122, 124 deferred
against 171.

A value struct reads and writes itself through the text I/O the catalog names
for it, so `Interval.In("1 day")` goes through MEOS's own parser and
`ToString()` through its printer, at the decimal digits the catalog's encoding
records. Nothing about the format is stated twice.

The rule excludes a struct a class already stands for, which is what keeps
`Npoint` and `Nsegment` one type each rather than a class and a struct spelling
the same value.

Four tests read the values back: a span answers its duration as an interval of
2 days, an interval round-trips its own text and raises on text MEOS refuses, a
span shifted and scaled by two intervals given as values lands where it should,
and a Frechet path arrives as the matches themselves — in the order the kernel
walks its distance matrix, from the last pair back to the first.
@estebanzimanyi
estebanzimanyi merged commit 10031da into MobilityDB:main Sep 3, 2026
1 check passed
@estebanzimanyi
estebanzimanyi deleted the feat/value-structs-by-value branch September 3, 2026 01:07
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