-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 IPPrefix Presto type #10816
Add IPPrefix Presto type #10816
Conversation
✅ Deploy Preview for meta-velox canceled.
|
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.
Thank you!
7f4a345
to
325df43
Compare
9cbaa6e
to
a0e4692
Compare
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.
Thanks!
@mbasmanova when you get a chance can you please take a look?
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.
exec::StringWriter<false> result(flatResult, row); | ||
if (v6Addr.isIPv4Mapped()) { | ||
result.append( | ||
v6Addr.createIPv4().str() + "/" + |
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.
Can we avoid creating and copying intermediate strings?
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.
Changed to fmt::format. Is this what you meant? Please let me know. Thanks!
}); | ||
} | ||
|
||
static auto splitIpSlashCidr(folly::StringPiece ipSlashCidr) { |
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.
Can we use std::string_view?
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.
I can switch to string view, but the function will get a little messy in that it will be switched to a find + creation of a vector<string_view> + creation of these string_views. This is used for error reporting and is taken straight from
Please let me know. Thanks!
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.
Update.
Maybe misinterpreted the comment. Changed function argument to std::string_view. Function itself is still using StringPiece.
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.
Reverted back to StringPiece, however switched to const &. string_view caused string output issue.
Expected error message to contain 'Invalid IP address '2001:db8::1::1'', but received 'Invalid IP address 'ck\0\0\0\0\0\0_�����''.
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.
@mbasmanova Thank you for your review. But I was not nearly careful enough given the issues you found that are real. I will have to re-review after all this is fixed.
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.
Looks good. Only some minor comments.
@mohsaka looks like one of the functions tests is failing. Might be related to your new type. Please take a look. |
c0ced7d
to
f8bc3d7
Compare
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.
@mohsaka : Did a very high level review. The code looks good. Will read it closely again.
@mohsaka Please squash your commits. Otherwise, looks good. |
0ec917a
to
946ff03
Compare
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.
Minor question on the doc external links.
946ff03
to
17cbb8c
Compare
046954c
to
d609537
Compare
d609537
to
2c1688c
Compare
@mbasmanova Could I get a review when you have the time? Thank you! |
return vec; | ||
} | ||
|
||
static void castFromString( |
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.
Is this logic consistent with Java ? Would the same invalid values return the same errors ?
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.
Not the same error message, but will return an error for the same input as java. The reason is that we are using folly for the parsing etc. I think a lot of changes will be necessary in the velox code if we want all of the error messages to match java for any library we are using, ex boost, folly.
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.
@mohsaka : I agree that it might not be possible to use the same errors in all places. But we should be as consistent as we can else its very hard during any kind of traffic migration to validate the builds. Meta has big issues with it.
In general, I feel it might be good to split this work as follows:
i) First PR just adds all the type classes for the IPPrefixType. So this PR minus all the casting code.
ii) Add the fuzzer for IPPrefix Casts that compares with Presto.
iii) Add the cast code with the fuzzer in place. That will ensure that we have most consistency. This would also make it simpler to validate the code you have in IPPrefixCastTest.
Based on prior experience I feel the fuzzer should not be an afterthought.
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.
4f4c6e7
to
b21aafa
Compare
Summary: Requested here to split off from the PR. #10816 (comment) Pull Request resolved: #11105 Reviewed By: Yuhta, amitkdutta Differential Revision: D63475266 Pulled By: kagamiori fbshipit-source-id: 11c7830b1cd4b665bc7915fd59b52673a7d39537
Current split PR for IPPREFIX type only here: |
Summary: This PR only adds the IPPrefix type classes. CAST logic is not implemented. The next PR for IPPrefix type will enhance the fuzzers for IPPrefix type. After that we will add the CAST logic so that it can be tested with fuzzers from the start itself. The full logic for IPPrefix is available in PRs : Original PR: #10538 Original Split PR: #10816 Pull Request resolved: #11122 Reviewed By: Yuhta Differential Revision: D64917429 Pulled By: pedroerp fbshipit-source-id: 2aef68d20de20673d9cc9239c98178ffc803860d
Summary: Requested here to split off from the PR. facebookincubator#10816 (comment) Pull Request resolved: facebookincubator#11105 Reviewed By: Yuhta, amitkdutta Differential Revision: D63475266 Pulled By: kagamiori fbshipit-source-id: 11c7830b1cd4b665bc7915fd59b52673a7d39537
Summary: This PR only adds the IPPrefix type classes. CAST logic is not implemented. The next PR for IPPrefix type will enhance the fuzzers for IPPrefix type. After that we will add the CAST logic so that it can be tested with fuzzers from the start itself. The full logic for IPPrefix is available in PRs : Original PR: facebookincubator#10538 Original Split PR: facebookincubator#10816 Pull Request resolved: facebookincubator#11122 Reviewed By: Yuhta Differential Revision: D64917429 Pulled By: pedroerp fbshipit-source-id: 2aef68d20de20673d9cc9239c98178ffc803860d
Written with similar comments addressed from #10650
Part of #10538
Some comments.
auto const vec = splitIpSlashCidr(ipAddressString);
is not outside the switch statement for efficiency. Don't want to re-parse if not necessary. Folly does the same but in a different way which seemed a little messy.https://github.com/facebook/folly/blob/556e17ac7b1f6cda68de789d5b06e79b2d3b990f/folly/IPAddress.cpp#L84C24-L84C37