-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Merge Request for #4809: provide a convenient method for C++ client producer batch container #4885
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
Conversation
…vide a convenient method callBack(const pulsar::Result& r), which directly invoke the pulsar::BatchMessageContainer::sendCallback_(r, pulsar::BatchMessageContainer::message_);
…vide a convenient method callBack(const pulsar::Result& r), which directly invoke the pulsar::BatchMessageContainer::sendCallback_(r, pulsar::BatchMessageContainer::message_);
…tainer, change iteration way.
// org.apache.pulsar.functions.worker.PulsarFunctionStateTest.testPulsarFunctionState (#4887) run java8 tests |
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.
@easyfan can you explain a bit more about this change? how it is convenient for c++ client?
@sijie I updated the description of this MR, add some simple messages about the thinking of the new method. |
Some more updates in the description. |
Change the Milestone to 2.4.2, because of conflict. |
…roducer batch container (#4885) provide a convenient method for C++ client producer batch container #4809 Formally the container element must be used like the following way: `MessageContainerList::iterator iter = messagesContainerListPtr->begin();` `iter->sendCallback_(r, iter->message_);` There are totally 3 reference operation steps inside: 1. Reference an exact element of MessageContainer explicitly from outside by iteration operator; 2. Reference the `sendCallback_` function pointer of said MessageContainer element explicitly from outside; 3. Reference the `message_` member of said MessageContainer element explicitly from outside; Besides, there is only one incoming variable say `Result r` is given from outside; In an ideal design, a user of `MessageContainer` should not have to know exactly the existence of `MessageContainer::sendCallback_` or `MessageContainer::message_`, what they exactly are, either how to use them. Organize those stuff in a right way, should be the responsibility of struct `MessageContainer` itself. So a reasonable convenient invoking method should be like: `MessageContainerList::iterator iter = messagesContainerListPtr->begin();` `iter->callBack(r);` And said `MessageContainer::callBack` function shall be implemented like below: `void callBack(const pulsar::Result& r) { sendCallback_(r, message_); }` Obviously, said convenient method is also an efficient one. Moreover, use a more efficient iteration method while going through the MessageContainerList; From some benchmark test result in my local environment, such "for iteration based a fixed-length", will be 5 times faster than the STL::iterator operator way. Refer to the change on BatchMessageContainer.cc, please. (cherry picked from commit 8058775)
provide a convenient method for C++ client producer batch container #4809
Formally the container element must be used like the following way:
MessageContainerList::iterator iter = messagesContainerListPtr->begin();
iter->sendCallback_(r, iter->message_);
There are totally 3 reference operation steps inside:
sendCallback_
function pointer of said MessageContainer element explicitly from outside;message_
member of said MessageContainer element explicitly from outside;Besides, there is only one incoming variable say
Result r
is given from outside;In an ideal design, a user of
MessageContainer
should not have to know exactly the existence ofMessageContainer::sendCallback_
orMessageContainer::message_
, what they exactly are, either how to use them. Organize those stuff in a right way, should be the responsibility of structMessageContainer
itself.So a reasonable convenient invoking method should be like:
MessageContainerList::iterator iter = messagesContainerListPtr->begin();
iter->callBack(r);
And said
MessageContainer::callBack
function shall be implemented like below:void callBack(const pulsar::Result& r) { sendCallback_(r, message_); }
Obviously, said convenient method is also an efficient one.
Moreover, use a more efficient iteration method while going through the MessageContainerList;
From some benchmark test result in my local environment, such "for iteration based a fixed-length", will be 5 times faster than the STL::iterator operator way.
Refer to the change on BatchMessageContainer.cc, please.