Skip to content

Remove per-query generation of built-in record type constructors#2603

Merged
ChristianGruen merged 3 commits intoBaseXdb:mainfrom
GuntherRademacher:record-type-constructors
Feb 18, 2026
Merged

Remove per-query generation of built-in record type constructors#2603
ChristianGruen merged 3 commits intoBaseXdb:mainfrom
GuntherRademacher:record-type-constructors

Conversation

@GuntherRademacher
Copy link
Member

This PR removes the per-query generation of built-in record type constructors in QueryParser. Instead, constructors for built-in record types are now registered once as standard functions via the Function enum.

The constructor signatures and parameter types are still derived from the Records enum (i.e., RecordType remains the single source of truth). A new Function(RecordType) constructor and corresponding helper methods in RecordType are used to generate:

  • the function signature string (e.g., name(a,b[,c])), and
  • the constructor parameter types (in declaration order).

At runtime, the constructor implementation creates either:

  • an XQRecordMap (for record types without optional fields), or
  • a regular XQMap (if optional fields are present).

This change eliminates the repeated initialization overhead per query execution while preserving existing semantics.

There is now some similarity between RecordType.constructor() and CRecord. I did not reuse CRecord, as the Function infrastructure requires a StandardFunc. However, CRecord could potentially be refactored to build upon RecordType.constructor(). I’m submitting this early as I’ll be unavailable for the next few days, but I’m happy to follow up on the CRecord refactoring afterwards.

@ChristianGruen
Copy link
Member

Thanks, looks fine.

However, CRecord could potentially be refactored to build upon RecordType.constructor().

I agree this sounds promising.

@ChristianGruen ChristianGruen merged commit 3ac469e into BaseXdb:main Feb 18, 2026
1 check passed
@ChristianGruen ChristianGruen deleted the record-type-constructors branch February 18, 2026 21:15
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.

2 participants