Skip to content

Build a temporal value from an array of temporal values - #25

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:gen/counted-array-arguments
Sep 2, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:gen/counted-array-arguments

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

MEOS reads an array of its own values through a pointer to the first element
and a count — tsequence_make, tsequenceset_make, temporal_merge_array
and the trgeometry twin of each. The object layer takes that as one C# array:
the wrappers' pointers are gathered into an IntPtr[] and pinned across the
call. The pin lasts exactly that long because the array is the caller's
throughout — tsequence_make_free is the twin that takes ownership, and it
does so by calling tsequence_make and then pfree_array on the array it
passed, which is sound only if tsequence_make neither frees nor retains it.
Eight constructors reach the object layer that way, 611 methods against 607.

The length parameter never appears in the C# signature, so it cannot disagree
with the array. That also settles which parameter is an array at all: the
length is named count, while a parameter named n is the index of the *_n
accessors, whose pointer is the receiver and no array — reading n as a
length turns trgeometry_instant_n(temp, n) into a call passing the
receiver's own length.

Three tests: a sequence made of three instants reads back as the text of all
three, merging two sequences answers four instants across two sequences, and
an empty array reaches MEOS as the invalid argument it is.

MEOS reads an array of its own values through a pointer to the first element
and a count — `tsequence_make`, `tsequenceset_make`, `temporal_merge_array`
and the trgeometry twin of each. The object layer takes that as one C# array:
the wrappers' pointers are gathered into an `IntPtr[]` and pinned across the
call. The pin lasts exactly that long because the array is the caller's
throughout — `tsequence_make_free` is the twin that takes ownership, and it
does so by calling `tsequence_make` and then `pfree_array` on the array it
passed, which is sound only if `tsequence_make` neither frees nor retains it.
Eight constructors reach the object layer that way, 611 methods against 607.

The length parameter never appears in the C# signature, so it cannot disagree
with the array. That also settles which parameter is an array at all: the
length is named `count`, while a parameter named `n` is the index of the `*_n`
accessors, whose pointer is the receiver and no array — reading `n` as a
length turns `trgeometry_instant_n(temp, n)` into a call passing the
receiver's own length.

Three tests: a sequence made of three instants reads back as the text of all
three, merging two sequences answers four instants across two sequences, and
an empty array reaches MEOS as the invalid argument it is.
@estebanzimanyi
estebanzimanyi merged commit 736cb79 into MobilityDB:main Sep 2, 2026
1 check passed
@estebanzimanyi
estebanzimanyi deleted the gen/counted-array-arguments branch September 2, 2026 21:53
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