Skip to content

Add function key expressions for computing record size and ternary expressions#4163

Draft
alecgrieser wants to merge 1 commit into
FoundationDB:mainfrom
alecgrieser:ternary-and-serialized-function-key-expressions
Draft

Add function key expressions for computing record size and ternary expressions#4163
alecgrieser wants to merge 1 commit into
FoundationDB:mainfrom
alecgrieser:ternary-and-serialized-function-key-expressions

Conversation

@alecgrieser
Copy link
Copy Markdown
Collaborator

This adds a few new useful function key expressions to allow users to specify more complicated ideas through key expressions.

The first is a record size function key expression. It behaves a bit like the VersionKeyExpression in that it doesn't really take arguments, and it returns a value (the serialized size) that comes from the FDBRecord rather than the non-record inputs into the expression.

The second is a ternary function key expression. It allows the user to define expressions like a.bool_field ? <expr1> : <expr2>. It would prepare us for some what more complicated expressions like a.x < 10 ? <expr1> : <expr2>. You could also theoretically implement a coaelsce function on top of it (x IS NULL ? y : x for coalesce(x, y)), but you are limited by the set of expressions that could actually be Booleans.

…pressions

This adds a few new useful function key expressions to allow users to specify more complicated ideas through key expressions.

The first is a record size function key expression. It behaves a bit like the `VersionKeyExpression` in that it doesn't really take arguments, and it returns a value (the serialized size) that comes from the `FDBRecord` rather than the non-record inputs into the expression.

The second is a ternary function key expression. It allows the user to define expressions like `a.bool_field ? <expr1> : <expr2>`. It would prepare us for some what more complicated expressions like `a.x < 10 ? <expr1> : <expr2>`. You could also theoretically implement a coaelsce function on top of it (`x IS NULL ? y : x` for `coalesce(x, y)`), but you are limited by the set of expressions that could actually be Booleans.
@alecgrieser alecgrieser added the enhancement New feature or request label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant