-
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
refactor: Fix deprecated errors when using shared_ptr::unique() #11318
refactor: Fix deprecated errors when using shared_ptr::unique() #11318
Conversation
✅ Deploy Preview for meta-velox canceled.
|
b0b166b
to
27fbeec
Compare
@@ -63,7 +63,7 @@ void prepareResult( | |||
result->encoding() == VectorEncoding::Simple::ARRAY) || | |||
(type->kind() == TypeKind::MAP && | |||
result->encoding() == VectorEncoding::Simple::MAP)) && | |||
result.unique())) { | |||
result.use_count() == 1)) { |
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 am wondering whether we should even rely on use_count as its unreliable , see for e.g : https://stackoverflow.com/a/77286276 .
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.
Correct, it is unreliable. This change is a 1-1 replacement for now. Using unique
was already unreliable and I guess that is why it is being removed. It will need some change eventually.
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.
Understood , I will create another issue to remove the use of shared_ptr::use_count == 1 from the code base as its unreliable and not meant for use across threads.
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.
Ahh, was about to create this issue :)
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.
@majetideepak FYI. |
27fbeec
to
83eb2af
Compare
@@ -99,7 +99,7 @@ void setConstantField( | |||
const VectorPtr& constant, | |||
vector_size_t size, | |||
VectorPtr& field) { | |||
if (field && field->isConstantEncoding() && field.unique() && | |||
if (field && field->isConstantEncoding() && field.use_count() == 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.
Should be field.use_count() == 1
? lets add () (field.use_count() == 1)
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.
We don't seem to use () around boolean expressions like these within if statements. So I didn't add it. I just added it when using macros where the argument is expanded to avoid any potential issues.
@@ -112,7 +112,7 @@ void setNullField( | |||
VectorPtr& field, | |||
const TypePtr& type, | |||
memory::MemoryPool* pool) { | |||
if (field && field->isConstantEncoding() && field.unique() && | |||
if (field && field->isConstantEncoding() && field.use_count() == 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.
(field.use_count() == 1)
?
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 only use the quotes when they are expression arguments into macros that could not be replaced e.g. with ASSERT_EQ.
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.
Yes, it is == 1
. mistake when fixing a merge conflict.
velox/vector/ComplexVector.cpp
Outdated
@@ -673,7 +673,7 @@ void RowVector::resize(vector_size_t newSize, bool setNotNull) { | |||
// to skip uniqueness check since effectively we are just changing | |||
// the length. | |||
if (newSize > oldSize) { | |||
VELOX_CHECK(child.unique(), "Resizing shared child vector"); | |||
VELOX_CHECK(child.use_count() == 1, "Resizing shared child vector"); |
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.
use VELOX_CHECK_EQ
83eb2af
to
ee3f458
Compare
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@czentgr Would you rebase to resolve merge conflicts? |
After the macOS CommandLineTools SDK15 (with Clang16), the new shared_ptr.h now issues the deprecated warnings for C++17 when using the shared_ptr::unique function. This function is removed for C++20. The solution is to replace the function with the actual implementation using use_count.
ee3f458
to
c52ceb4
Compare
@mbasmanova I've completed the rebase and resolved the conflict. |
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@mbasmanova merged this pull request in ef4614d. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
After the macOS CommandLineTools SDK15 (with Clang16), the new shared_ptr.h now issues the deprecated warnings for C++17 when using the shared_ptr::unique function. This function is removed for C++20.
The solution is to replace the function with the actual implementation using use_count.
Example error:
Resolves: #11342