github-actions[bot] commented on code in PR #28698: URL: https://github.com/apache/doris/pull/28698#discussion_r1432410931
########## be/src/pipeline/exec/exchange_sink_buffer.h: ########## @@ -71,25 +72,53 @@ struct AtomicWrapper { // We use BroadcastPBlockHolder to hold a broadcasted PBlock. For broadcast shuffle, one PBlock // will be shared between different channel, so we have to use a ref count to mark if this // PBlock is available for next serialization. +class BroadcastPBlockHolderQueue; class BroadcastPBlockHolder { + ENABLE_FACTORY_CREATOR(BroadcastPBlockHolder); + +public: + BroadcastPBlockHolder() { _pblock = std::make_unique<PBlock>(); } + BroadcastPBlockHolder(std::unique_ptr<PBlock>&& pblock) { _pblock = std::move(pblock); } + ~BroadcastPBlockHolder(); + + PBlock* get_block() { return _pblock.get(); } + +private: + friend class BroadcastPBlockHolderQueue; + std::unique_ptr<PBlock> _pblock; + std::weak_ptr<BroadcastPBlockHolderQueue> _parent_creator; + void set_parent_creator(std::shared_ptr<BroadcastPBlockHolderQueue> parent_creator) { + _parent_creator = parent_creator; + } +}; + +// Use a stack inside to ensure that the PBlock is in cpu cache +class BroadcastPBlockHolderQueue : public std::enable_shared_from_this<BroadcastPBlockHolderQueue> { + ENABLE_FACTORY_CREATOR(BroadcastPBlockHolderQueue); + public: - BroadcastPBlockHolder() : _ref_count(0), _dep(nullptr) {} - BroadcastPBlockHolder(pipeline::BroadcastDependency* dep) : _ref_count(0), _dep(dep) {} - ~BroadcastPBlockHolder() noexcept = default; + BroadcastPBlockHolderQueue() = default; - void ref(int delta) noexcept { _ref_count._value.fetch_add(delta); } - void unref() noexcept; - void ref() noexcept { ref(1); } + BroadcastPBlockHolderQueue( + std::shared_ptr<pipeline::BroadcastDependency>& broadcast_dependency) { + _broadcast_dependency = broadcast_dependency; + } - bool available() { return _ref_count._value == 0; } + void push(std::shared_ptr<BroadcastPBlockHolder> holder); - PBlock* get_block() { return &pblock; } + bool empty() { Review Comment: warning: method 'empty' can be made static [readability-convert-member-functions-to-static] ```suggestion static bool empty() { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org