You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by Derek Chen-Becker <de...@precog.com> on 2012/06/29 18:03:00 UTC

Is DefaultEventHandler.collate sort order important?

I'm working on a patch to allow for cross-building kafka to both scala 2.8.0 and 2.9.x, and I'm down to one very minor snag in the unit tests. In AsyncProducerTest, the testCollateAndSerializeEvents test fails because default HashMap ordering for toArray (used by DefaultEventHandler.collate) changed between versions. The EasyMock expected call for multisend then fails because the ProducerRequests aren't in the same order:

  Unexpected method call multiSend([ProducerRequest(test-topic,0,70), ProducerRequest(test1$topic,0,75), ProducerRequest(test1$topic,1,75), ProducerRequest(test-topic,1,70)]):
    multiSend([ProducerRequest(test1$topic,1,75), ProducerRequest(test-topic,0,70), ProducerRequest(test-topic,1,70), ProducerRequest(test1$topic,0,75)]): expected: 1, actual: 0

Is sort order of the keys significant in any way, and if not would the preferred fix be a change to the EasyMock matcher to ignore order for the argument? Or would it be preferable to do a stable sort (perhaps change collate to return a List[(String,Int), Seq[T]])?

Thanks,

Derek

--
Derek Chen-Becker
Lead Infrastructure Engineer
derek@precog.com
303-752-1700


Re: Is DefaultEventHandler.collate sort order important?

Posted by Jun Rao <ju...@gmail.com>.
Derek,

The ordering of those ProducerRequests doesn't really matter. It seems that
the easiest way to fix this is to ask EasyMock to ignore ordering.

Thanks,

Jun

On Fri, Jun 29, 2012 at 9:03 AM, Derek Chen-Becker <de...@precog.com> wrote:

> I'm working on a patch to allow for cross-building kafka to both scala
> 2.8.0 and 2.9.x, and I'm down to one very minor snag in the unit tests. In
> AsyncProducerTest, the testCollateAndSerializeEvents test fails because
> default HashMap ordering for toArray (used by DefaultEventHandler.collate)
> changed between versions. The EasyMock expected call for multisend then
> fails because the ProducerRequests aren't in the same order:
>
>  Unexpected method call multiSend([ProducerRequest(test-topic,0,70),
> ProducerRequest(test1$topic,0,75), ProducerRequest(test1$topic,1,75),
> ProducerRequest(test-topic,1,70)]):
>    multiSend([ProducerRequest(test1$topic,1,75),
> ProducerRequest(test-topic,0,70), ProducerRequest(test-topic,1,70),
> ProducerRequest(test1$topic,0,75)]): expected: 1, actual: 0
>
> Is sort order of the keys significant in any way, and if not would the
> preferred fix be a change to the EasyMock matcher to ignore order for the
> argument? Or would it be preferable to do a stable sort (perhaps change
> collate to return a List[(String,Int), Seq[T]])?
>
> Thanks,
>
> Derek
>
> --
> Derek Chen-Becker
> Lead Infrastructure Engineer
> derek@precog.com
> 303-752-1700
>
>