-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Reimplement JsonExpressionParser in terms of jsonparser #8734
Reimplement JsonExpressionParser in terms of jsonparser #8734
Conversation
for _, p := range paths { | ||
switch v := p.(type) { | ||
case int: | ||
stingPaths = append(stingPaths, fmt.Sprintf("[%d]", v)) |
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.
The index syntax for paths in jsonparser
differs slightly from jsoniter
. This function turns our representation into what is expected by the new implementation
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.
Great work @MasslessParticle! Really excited for this. I'd be keen to see how this stacks up against the regular json parser; if it's now faster/more resource-efficient, we can start recommending its use when specific keys are needed.
Added a comment about error handling, but overall LGTM
pkg/logql/log/parser.go
Outdated
return line, true | ||
} | ||
|
||
func isValidJSONStart(data []byte) bool { | ||
switch data[0] { | ||
case '"', '{', '}', '[', ']': |
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.
Are closing brackets really valid JSON start tokens?
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.
Good catch, thanks! This is copy paste from the parser internals
@dannykopping Here's @cyriltovena's original PR for JSON Parser: #7723. the |
@dannykopping It's interesting to note that when the JSON payload is small and doesn't contain nested keys, the JSON Parser performs about as well as |
This reverts commit 9c6e509.
This PR reimplements the functionality of
JSONExpressionParser
using thejsonparser
library rather thanjsoniter
Benchmarks: