Skip to content
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

Review jsonpath_rs (2) #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Review jsonpath_rs (2) #11

wants to merge 6 commits into from

Conversation

oshadmi
Copy link

@oshadmi oshadmi commented Aug 28, 2022

Replace #10

Few comments up til now:

  • Do we need to support/test filter with full_scan or all? (currently it seems to be allowed by the grammar)
  • We should probably add more comments in code
  • Did not get the flat_arrays_on_filter - you mean we should not iterate all array entries, but only the relevant ones (e.g., if using a union, no need to iterate all?)
    And not sure I understand, for example, in calc_internal in Rule::filter in the else clause we pass true and not the param we got flat_arrays_on_filter
  • Added tests which panicked (filter_inner, filter_nested) so they are commented out to be reviewed later

@oshadmi oshadmi mentioned this pull request Aug 28, 2022
@MeirShpilraien
Copy link
Collaborator

Do we need to support/test filter with full_scan or all? (currently it seems to be allowed by the grammar)

Yes, but lets leave it to a separate PR

We should probably add more comments in code

Agree, will add it on this PR.

Did not get the flat_arrays_on_filter - you mean we should not iterate all array entries, but only the relevant ones (e.g., if using a union, no need to iterate all?)
And not sure I understand, for example, in calc_internal in Rule::filter in the else clause we pass true and not the param we got flat_arrays_on_filter

The json path rules was not clear to me, But I believe I understand now, if the filter is applied on simple value (string, number, boolean, ...) then it is applied on that value. But if it is applied on array or object, it is applies on each element. I will change the code, we might not need the flat_arrays_on_filter at all.

Added tests which panicked (filter_inner, filter_nested) so they are commented out to be reviewed later

Saw that, will fix them.

Copy link
Author

@oshadmi oshadmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 Few comments

src/json_path.rs Outdated Show resolved Hide resolved
src/json_path.rs Outdated Show resolved Hide resolved
src/json_path.rs Outdated Show resolved Hide resolved
src/grammer.pest Show resolved Hide resolved
tests/filter.rs Show resolved Hide resolved
@@ -913,32 +922,33 @@ impl<'i, UPTG: UserPathTrackerGenerator> PathCalculator<'i, UPTG> {
self.calc_range(pairs, curr, json, path_tracker, calc_data);
}
Rule::filter => {
if flat_arrays_on_filter && json.get_type() == SelectValueType::Array {
if json.get_type() == SelectValueType::Array
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any impact on performance from this change? (always flattening also without filter)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I can think of...

MeirShpilraien and others added 2 commits September 15, 2022 14:34
Co-authored-by: Omer Shadmi <76992134+oshadmi@users.noreply.github.com>
@MeirShpilraien
Copy link
Collaborator

@oshadmi fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants