-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Record accessor helper #1637
Record accessor helper #1637
Conversation
@mururu Could you check this patch? |
Bench result:
|
I thought jsonpath supports |
@sonots yes. In fluentd case, mix case seems no merits. |
Well, I feel allowing users to write I agree that it makes parsing a bit complex and consumes time, but I think it is acceptable tradeoff because parser usually runs only once at "configure". |
Yes, it doesn't have a impact at runtime. This is just jsonpath like, not jsonpath, so I don't think following similar syntax is not must. For documentation and maintainance, separating two way is less cost at the baseline. |
We need to get users' opinions. As one user, I like to get allowed |
assert_equal ['key1', 'key2', 0], result | ||
end | ||
|
||
data('dot' => '$.key1[0].ke y2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is acceptable? It looks wierd for me. I think we should not allow it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think typical jsonpath parser does not accept this. At least https://github.com/json-path/JsonPath did not accept this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems javascript object limitation. javascript object field can't contain space.
But fluentd target is an event record, so there is no such limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am against to extend specifications because it makes difficult to refactor implementation later (for example, think of changing jsonpath parser to 3rd party implementation later) without breaking backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a plan to use 3rd party jsonpath parser because this is just jsonpath like, not jsonpath. jsonpath has lots of useless feature in fluentd, e.g.g filter, wildcard and etc.
So we want limited well-known syntax, not entire jsonpath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But limiting several characters in dot notation is not bad idea because bracket notation is straight way for such cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't strongly oppose this, but it just looks weird for me too.
|
Minor comment: When parsing |
@mururu Good catch. I will add more validation. |
Applied reviews and improve the performance for single key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Implement record_accessor helper for nested record support.
Support two jsonpath like syntaxes.
$.key1.key2[0]
$['key1'][0]['this.is.key2']
key
In this patch, I also update
filter_grep
to use this helper.NOTE: I implement Accessor with normal way. If need the performance, I will change its implementaion to eval way: https://gist.github.com/repeatedly/ab553ed260cd080bd01ec71da9427312