Skip to content

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

Merged
merged 5 commits into from
Aug 8, 2019

Conversation

easyfan
Copy link
Contributor

@easyfan easyfan commented Aug 5, 2019

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.

ZhengFan added 5 commits August 5, 2019 10:21
…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_);
@easyfan easyfan marked this pull request as ready for review August 5, 2019 06:32
@sijie
Copy link
Member

sijie commented Aug 5, 2019

// org.apache.pulsar.functions.worker.PulsarFunctionStateTest.testPulsarFunctionState (#4887)

run java8 tests

Copy link
Member

@sijie sijie left a 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?

@easyfan
Copy link
Contributor Author

easyfan commented Aug 6, 2019

@sijie I updated the description of this MR, add some simple messages about the thinking of the new method.

@easyfan
Copy link
Contributor Author

easyfan commented Aug 6, 2019

Some more updates in the description.

@sijie sijie merged commit 8058775 into apache:master Aug 8, 2019
@easyfan easyfan deleted the f_master_ branch August 8, 2019 01:31
@wolfstudy wolfstudy modified the milestones: 2.5.0, 2.4.2 Nov 19, 2019
@wolfstudy
Copy link
Member

Change the Milestone to 2.4.2, because of conflict.

wolfstudy pushed a commit that referenced this pull request Nov 20, 2019
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants