Skip to content
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

BatchMessageIdImpl can be compared to MessageIdImpl #1285

Merged
merged 1 commit into from
Feb 26, 2018

Conversation

ivankelly
Copy link
Contributor

A batch message id is a MessageIdImpl with a batchIndex >=
0. Therefore, they can be compared to MessageIdImpl. If all fields
other than the batchIndex are equal to a messageId, the
BatchMessageIdImpl can compare its batchIndex with -1. If it is -1, it
matches the MessageIdImpl. If it is greater than -1, then it is
greater than the MessageIdImpl.

A batch message id is a MessageIdImpl with a batchIndex >=
0. Therefore, they can be compared to MessageIdImpl. If all fields
other than the batchIndex are equal to a messageId, the
BatchMessageIdImpl can compare its batchIndex with -1. If it is -1, it
matches the MessageIdImpl. If it is greater than -1, then it is
greater than the MessageIdImpl.
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@merlimat merlimat added this to the 2.0.0-incubating milestone Feb 26, 2018
@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Feb 26, 2018
@merlimat merlimat merged commit 4f1f02b into apache:master Feb 26, 2018
sijie pushed a commit that referenced this pull request Mar 28, 2020
…nd BatchMessageId (#6621)

link PR: #1285
This PR resolve the compare from BatchMessageIdImpl to MessageIdImpl, but didn't consider the 
symmetry on the other side.

Master Issue: #6433

Motivation
Fix the bug of compare between MessageId and BatchMessageId, keep the symmetry of compareTo method.

Modifications
In the mothod of compareTo in BatchMessageId class, when compare to non-batched messageId and other properties is equal,if batchIndex >-1, then return 1, so in MessageId class, add the same logic, and if batchIndex >-1, then return -1.

Verifying this change
Unit tests added.
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
…nd BatchMessageId (apache#6621)

link PR: apache#1285
This PR resolve the compare from BatchMessageIdImpl to MessageIdImpl, but didn't consider the 
symmetry on the other side.

Master Issue: apache#6433

Motivation
Fix the bug of compare between MessageId and BatchMessageId, keep the symmetry of compareTo method.

Modifications
In the mothod of compareTo in BatchMessageId class, when compare to non-batched messageId and other properties is equal,if batchIndex >-1, then return 1, so in MessageId class, add the same logic, and if batchIndex >-1, then return -1.

Verifying this change
Unit tests added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants