Conversation
Co-authored-by: simbo1905 <simbo1905@60hertz.com>
Co-authored-by: simbo1905 <simbo1905@60hertz.com>
|
Cursor Agent can help with this pull request. Just |
Summary of ChangesHello @simbo1905, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4530a3c6cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| default -> | ||
| sb.append(" s = Stream.empty();\n"); |
There was a problem hiding this comment.
Handle recursive-descent array indices in compiled paths
The compiler’s recursive-descent emitter only handles property names and wildcards, and falls through to Stream.empty() for everything else. That means expressions like ..[0] (which the parser allows and the AST interpreter currently supports in JsonPathAstInterpreter.evaluateTargetSegment) will return no results once compile() is used. This is a behavior regression specific to compiled paths: the AST-backed evaluator still resolves recursive array indices. Consider emitting a recursive-index selector (mirroring the interpreter’s ArrayIndex handling) instead of dropping to empty.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Code Review
This pull request introduces a major new feature: runtime compilation of JsonPath expressions for improved performance on hot paths. The implementation is well-structured, refactoring the original JsonPath class into a clean interface and several new classes with distinct responsibilities: an AST-based interpreter, a runtime compiler, and a runtime library for the compiled code. The code is of high quality, with good fallback mechanisms and thorough tests.
My main feedback is a minor inconsistency in logging behavior between the AST-based and the new compiled implementations. I've added a specific comment with a suggestion to align them for better diagnostics.
| final class JsonPathCompiledPath implements JsonPathCompiled { | ||
|
|
||
| private final String expression; | ||
| private final String generatedClassName; | ||
| private final String javaSource; | ||
| private final JsonPath delegate; | ||
|
|
||
| JsonPathCompiledPath(String expression, String generatedClassName, String javaSource, JsonPath delegate) { | ||
| this.expression = Objects.requireNonNull(expression, "expression must not be null"); | ||
| this.generatedClassName = Objects.requireNonNull(generatedClassName, "generatedClassName must not be null"); | ||
| this.javaSource = Objects.requireNonNull(javaSource, "javaSource must not be null"); | ||
| this.delegate = Objects.requireNonNull(delegate, "delegate must not be null"); | ||
| } | ||
|
|
||
| @Override | ||
| public List<JsonValue> query(JsonValue json) { | ||
| return delegate.query(json); | ||
| } |
There was a problem hiding this comment.
The compiled path's query method just delegates, but this misses the FINE-level logging that the AST-based implementation has. To ensure consistent behavior for diagnostics, logging should be added here. This wrapper is the ideal place for such cross-cutting concerns.
final class JsonPathCompiledPath implements JsonPathCompiled {
private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(JsonPathCompiledPath.class.getName());
private final String expression;
private final String generatedClassName;
private final String javaSource;
private final JsonPath delegate;
JsonPathCompiledPath(String expression, String generatedClassName, String javaSource, JsonPath delegate) {
this.expression = Objects.requireNonNull(expression, "expression must not be null");
this.generatedClassName = Objects.requireNonNull(generatedClassName, "generatedClassName must not be null");
this.javaSource = Objects.requireNonNull(javaSource, "javaSource must not be null");
this.delegate = Objects.requireNonNull(delegate, "delegate must not be null");
}
@Override
public List<JsonValue> query(JsonValue json) {
// The delegate also performs this check, but we log before calling.
Objects.requireNonNull(json, "json must not be null");
LOG.fine(() -> "Querying document with compiled path: " + this);
return delegate.query(json);
}Co-authored-by: simbo1905 <simbo1905@60hertz.com>
Co-authored-by: simbo1905 <simbo1905@60hertz.com>
Co-authored-by: simbo1905 <simbo1905@60hertz.com>
This pull request contains changes generated by a Cursor Cloud Agent