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

Add support for using negative array indices in json path #11451

Closed

Conversation

bikramSingh91
Copy link
Contributor

This allows the use of negative array indices in json path to access
elements from the end.

Test Plan:
Added unit tests

@bikramSingh91 bikramSingh91 requested a review from kgpai November 6, 2024 01:29
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 6, 2024
Copy link

netlify bot commented Nov 6, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit e936f6e
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/672bc91e439c930008368786

@@ -122,6 +122,7 @@ void extractArray(
auto rv = folly::tryTo<int32_t>(key);
if (rv.hasValue()) {
auto idx = rv.value();
idx = idx >= 0 ? idx : arrayLen + idx;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: arrayLen + idx wont overflow I suppose .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wont, arrayLen will always be non-negative and the addition is only done when idx is negative.
However, I did notice that arrayLen is size_t and idx is int32_t which can brittle when it comes to implicit conversions applied by the compiler. Therefore, I have explicitly changes both to int64_t.

@facebook-github-bot
Copy link
Contributor

@bikramSingh91 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

This allows the use of negative array indices in json path to access elements from the end.

Test Plan:
Added unit tests
@facebook-github-bot
Copy link
Contributor

@bikramSingh91 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bikramSingh91
Copy link
Contributor Author

There is a failure in Linux Build tests due to an unrelated flaky test: Flaky AsyncDataCacheTest.ssdWriteOptions #11463

@facebook-github-bot
Copy link
Contributor

@bikramSingh91 merged this pull request in d1bf9da.

Copy link

Conbench analyzed the 1 benchmark run on commit d1bf9da3.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants