-
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
- Fix FlatVector copy memory issue (#11482) #11483
base: main
Are you sure you want to change the base?
Conversation
Summary: When copy-ing a FlatVector the source memory pool is used. This is a problem when the vector needs to live beyond the lifetime of the source pool. For strings this requires recomputing new StringViews over newly copied string buffers. This is useful in cases where you need to maintain result rows beyond the lifetime of a given presto task / query. Reviewed By: arhimondr Differential Revision: D65306907
✅ Deploy Preview for meta-velox canceled.
|
This pull request was exported from Phabricator. Differential Revision: D65306907 |
@@ -274,12 +274,13 @@ class FlatVector final : public SimpleVector<T> { | |||
|
|||
VectorPtr copyPreserveEncodings( | |||
velox::memory::MemoryPool* pool = nullptr) const override { | |||
auto allocPool = pool ? pool : BaseVector::pool_; |
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.
const auto
template <> | ||
VectorPtr FlatVector<StringView>::copyPreserveEncodings( | ||
velox::memory::MemoryPool* pool) const { | ||
auto allocPool = pool ? pool : BaseVector::pool_; |
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.
const auto
auto newValuesBuffer = | ||
AlignedBuffer::allocate<StringView>(BaseVector::size(), allocPool); | ||
auto rawCopyValues = newValuesBuffer->asMutable<StringView>(); | ||
// Copy non Null StringViews to value buffer |
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.
.
in the end
} | ||
} | ||
|
||
BufferPtr newStringBuffer = nullptr; |
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.
std::vector stringBuffers, and emplace_back to it if have
Please remove - in the title |
Summary:
When copy-ing a FlatVector the source memory pool is used. This is a problem when the vector needs to live beyond the lifetime of the source pool.
For strings this requires recomputing new StringViews over newly copied string buffers. This is useful in cases where you need to maintain result rows beyond the lifetime of a given presto task / query.
Reviewed By: arhimondr
Differential Revision: D65306907