Add function key expressions for computing record size and ternary expressions#4163
Draft
alecgrieser wants to merge 1 commit into
Draft
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
VersionKeyExpressionin that it doesn't really take arguments, and it returns a value (the serialized size) that comes from theFDBRecordrather 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 likea.x < 10 ? <expr1> : <expr2>. You could also theoretically implement a coaelsce function on top of it (x IS NULL ? y : xforcoalesce(x, y)), but you are limited by the set of expressions that could actually be Booleans.