-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filterx: set_fields()
#397
Merged
Merged
Conversation
This file contains 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
alltilla
added a commit
to alltilla/axosyslog
that referenced
this pull request
Nov 28, 2024
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
force-pushed
the
filterx-set-fields
branch
from
November 28, 2024 10:44
296a462
to
1bd210e
Compare
alltilla
added a commit
to alltilla/axosyslog
that referenced
this pull request
Nov 28, 2024
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
force-pushed
the
filterx-set-fields
branch
from
November 28, 2024 10:50
1bd210e
to
7462b7a
Compare
alltilla
added a commit
to alltilla/axosyslog
that referenced
this pull request
Nov 28, 2024
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
force-pushed
the
filterx-set-fields
branch
from
November 28, 2024 11:46
7462b7a
to
ecd5798
Compare
alltilla
added a commit
to alltilla/axosyslog
that referenced
this pull request
Nov 28, 2024
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
force-pushed
the
filterx-set-fields
branch
from
November 28, 2024 11:47
ecd5798
to
583f8c8
Compare
MrAnno
reviewed
Nov 29, 2024
Signed-off-by: Attila Szakacs <[email protected]>
Signed-off-by: Attila Szakacs <[email protected]>
The inner generator part of the code is a workaround for the grammar, and is not very clean to have. We would like to iterate through it in some expr ctors, like it was a normal literal generator. Also the len() function could be useful somewhere. Removing the literal inner generators would be a bigger task, so I just hacked the literal generator API a bit to support literal inner generators. Signed-off-by: Attila Szakacs <[email protected]>
We store overrides and defaults for the modified dict's fields. Later on we will iterate on these and set the field's value with the first valid expression. Signed-off-by: Attila Szakacs <[email protected]>
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
added a commit
to alltilla/axosyslog
that referenced
this pull request
Nov 29, 2024
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
force-pushed
the
filterx-set-fields
branch
from
November 29, 2024 14:06
583f8c8
to
1b42b08
Compare
If there are overrides defined for the field, we first iterate through them, and if there is an expression that successfully evaluated, we set it. If overrides were not effective, and the field already has a value, we are done with this field, we leave it as it is. If, however it did not have a value, we iterate through the defaults, like we did with the overrides, and set the field accordingly. Signed-off-by: Attila Szakacs <[email protected]>
Signed-off-by: Attila Szakacs <[email protected]>
Signed-off-by: Attila Szakacs <[email protected]>
alltilla
force-pushed
the
filterx-set-fields
branch
from
November 29, 2024 14:39
1b42b08
to
633e2b7
Compare
MrAnno
approved these changes
Nov 29, 2024
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.
A recurring pattern in FilterX is to take a dict and set multiple fields in it with overrides or defaults.
set_fields()
takes a dict as the first argument andoverrides
anddefaults
as optional parameters.overrides
anddefaults
are also dicts, where the key is the field's name, and the value is either an expression, ora list of expressions. If a list is provided, each expression will be evaluated, and the first successful, non-
null
one willbe used to set the respective field's value. This is similar to chaining null-coalescing (
??
) operators, but is more performant.overrides
are always processed for each field. Thedefaults
for a field are only processed, if the field does not already have a value set.Example usage: