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

fix: validate empty object/array in ast Get #383

Merged
merged 5 commits into from
Mar 14, 2023
Merged

fix: validate empty object/array in ast Get #383

merged 5 commits into from
Mar 14, 2023

Conversation

liuq19
Copy link
Collaborator

@liuq19 liuq19 commented Mar 14, 2023

validate empty object or array when get_by_path

performance:

goarch: amd64
pkg: github.com/bytedance/sonic/ast
cpu: Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz
               │ /tmp/tmpfnkd86xm.source.txt │  /tmp/tmpmbt6i4rj.target.txt  │
               │           sec/op            │   sec/op     vs base          │
GetOne_Sonic-8                   3.122µ ± 3%   3.086µ ± 6%  ~ (p=0.971 n=10)

               │ /tmp/tmpfnkd86xm.source.txt │  /tmp/tmpmbt6i4rj.target.txt   │
               │             B/s             │     B/s       vs base          │
GetOne_Sonic-8                  3.885Gi ± 4%   3.933Gi ± 5%  ~ (p=0.971 n=10)

               │ /tmp/tmpfnkd86xm.source.txt │  /tmp/tmpmbt6i4rj.target.txt   │
               │            B/op             │    B/op     vs base            │
GetOne_Sonic-8                    24.00 ± 0%   24.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

               │ /tmp/tmpfnkd86xm.source.txt │  /tmp/tmpmbt6i4rj.target.txt   │
               │          allocs/op          │ allocs/op   vs base            │
GetOne_Sonic-8                    1.000 ± 0%   1.000 ± 0%  ~ (p=1.000 n=10) ¹

// {`{"a":null}`, []interface{}{"a", "b", 0}, ErrNotExist},
{`{"":{"b":123}}`, []interface{}{"b"}, ErrNotExist},
{`{"a":{"b":123}}`, []interface{}{"b"}, ErrNotExist},
{`{"a":{"b":123}}`, []interface{}{"b", "b"}, ErrNotExist},
Copy link
Collaborator

Choose a reason for hiding this comment

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

可以加个多级测试用例,例如

{`{"a":{"b":123}}`, []interface{}{"a", "c"}, ErrNotExist}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

好的,已经加了

@liuq19 liuq19 enabled auto-merge (squash) March 14, 2023 04:40
@liuq19 liuq19 merged commit 8f1e08c into bytedance:main Mar 14, 2023
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.

2 participants