Jun Rao,
        Thanks for taking time reviewing the patch. Would like to confirm
here is what you suggested to do:

        1. Utils.abs will be renamed to Utils.toPositive
        2. Make changes in these methods of class DefaultPartitioner and
ByteArrayPartitioner so that toPositive gets called in partition method.

                def partition(key: Any, numPartitions: Int): Int = {
                        Utils.abs(key.hashCode) % numPartitions
                }


        I can certainly make the above changes.  however method abs gets used
many other places and making the case worse is that there are two abs
methods both in core and clients. I found this problem when I was in an
effort of addressing issue 1926. For now, what if I keep that method in
clients, remove the one in core Utils module and making changes to all
other modules where abs method gets called so that all use of abs method
will point to the clients Utils.abs instead of two locations?

Thanks.

Tong Li
OpenStack & Kafka Community Development
Building 501/B205
liton...@us.ibm.com

"Jun Rao (JIRA)" <j...@apache.org> wrote on 02/27/2015 12:43:04 AM:

> From: "Jun Rao (JIRA)" <j...@apache.org>
> To: dev@kafka.apache.org
> Date: 02/27/2015 12:43 AM
> Subject: [jira] [Commented] (KAFKA-1988)
> org.apache.kafka.common.utils.Utils.abs method returns wrong value
> for negative numbers.
>
>
>     [ https://issues.apache.org/jira/browse/KAFKA-1988?
> page=com.atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel&focusedCommentId=14339751#comment-14339751 ]
>
> Jun Rao commented on KAFKA-1988:
> --------------------------------
>
> Actually, we can probably keep the same logic in determining the
> partition from key in Partitioner. We  can move the current code in
> abs() into Partitioner, and give it a new name like toPositive().
> Then we can replace Utils.abs() with toPositive() it in the
> following code in Partitioner.
>
>             // hash the key to choose a partition
>             return Utils.abs(Utils.murmur2(key)) % numPartitions;
>
> This way, we will preserve the key distribution of existing users of
> the new producer.
>
> Tong,
>
> Do you want to submit a new patch based on that?
>
>
>
> > org.apache.kafka.common.utils.Utils.abs method returns wrong value
> for negative numbers.
> >
>
----------------------------------------------------------------------------------------

> >
> >                 Key: KAFKA-1988
> >                 URL: https://issues.apache.org/jira/browse/KAFKA-1988
> >             Project: Kafka
> >          Issue Type: Bug
> >    Affects Versions: 0.8.2.0
> >            Reporter: Tong Li
> >            Assignee: Tong Li
> >            Priority: Blocker
> >             Fix For: 0.8.2.1
> >
> >         Attachments: KAFKA-1988.patch
> >
> >
> > org.apache.kafka.common.utils.Utils.abs method returns wrong value
> for negative numbers. The method only returns intended value for
> positive numbers. All negative numbers except the Integer.Min_Value
> will be returned an unsigned integer.
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)
>

Reply via email to