You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mrunit.apache.org by Dipesh Khakhkhar <di...@gmail.com> on 2012/11/28 06:14:24 UTC
Mapper unit test failing - validation failing
I'm using MRUnit to test my M/R classes.
My mapper is simple one
- It takes input file with input like
1
2
3
- Its outputs is
Key 0,0,0
Value 1,
key 0,0,1
Value 2,
Now I am using MRUnit to test my mapper with following input and expected
output -
Input: "1"
Expected Output: like this mapDriver.withOutput(key, new Text("1,") ); //
where my key is 0,0,0
I'm getting following error
java.lang.AssertionError: 2 Error(s): (Missing expected output (0,0,0,, 1,)
at position 0., Received unexpected output (0,0,0,, 1,) at position 0.)
It seems to me my output is correct (lhs==rhs) - am i missing something
above? Please correct me if I'm wrong.
Thanks in advance for replying and answering my query.
Thanks.
Re: Mapper unit test failing - validation failing
Posted by Dipesh Khakhkhar <di...@gmail.com>.
Found the problem - I have to use my customized equals or compare method as
I have List<Object> and there were different objects and as a result of
that it was failing.
Thanks.
On Wed, Nov 28, 2012 at 12:44 PM, Dipesh Khakhkhar <dipeshsoftware@gmail.com
> wrote:
> Brock,
> Thanks for replying. Yes I am using a custom key. After searching I found
> that I have to override equals and hashcode method.
>
> In my custom key, I am using list of objects i.e. List<Object> as it's
> member variable and i tried to use the following -
>
> public boolean equals(Object o) {
> if (o instanceof MyCustomKey) {
> MyCustomKey myKey = (MyCustomKey) o;
> return mylist.equals(myKey.getList()) ;
> }
> return false;
> }
>
> but the above call is failing. In eclipse debugger it is showing same
> values and size for both the lists but myKey.getList() has different
> modCount than myList.
>
> I have overridden hashcode method too. Am i missing something above?
>
> Thanks.
>
>
> On Wed, Nov 28, 2012 at 7:58 AM, Brock Noland <br...@cloudera.com> wrote:
>
>> What are you using for output Key? Is it a custom writable?
>>
>>
>> On Tue, Nov 27, 2012 at 11:14 PM, Dipesh Khakhkhar <
>> dipeshsoftware@gmail.com> wrote:
>>
>>> I'm using MRUnit to test my M/R classes.
>>>
>>> My mapper is simple one
>>>
>>> - It takes input file with input like
>>> 1
>>> 2
>>> 3
>>>
>>> - Its outputs is
>>> Key 0,0,0
>>> Value 1,
>>>
>>> key 0,0,1
>>> Value 2,
>>>
>>> Now I am using MRUnit to test my mapper with following input and
>>> expected output -
>>>
>>> Input: "1"
>>> Expected Output: like this mapDriver.withOutput(key, new Text("1,") );
>>> // where my key is 0,0,0
>>>
>>> I'm getting following error
>>>
>>> java.lang.AssertionError: 2 Error(s): (Missing expected output (0,0,0,,
>>> 1,) at position 0., Received unexpected output (0,0,0,, 1,) at position 0.)
>>>
>>> It seems to me my output is correct (lhs==rhs) - am i missing something
>>> above? Please correct me if I'm wrong.
>>>
>>> Thanks in advance for replying and answering my query.
>>>
>>> Thanks.
>>>
>>>
>>
>>
>> --
>> Apache MRUnit - Unit testing MapReduce -
>> http://incubator.apache.org/mrunit/
>>
>
>
Re: Mapper unit test failing - validation failing
Posted by Dipesh Khakhkhar <di...@gmail.com>.
Brock,
Thanks for replying. Yes I am using a custom key. After searching I found
that I have to override equals and hashcode method.
In my custom key, I am using list of objects i.e. List<Object> as it's
member variable and i tried to use the following -
public boolean equals(Object o) {
if (o instanceof MyCustomKey) {
MyCustomKey myKey = (MyCustomKey) o;
return mylist.equals(myKey.getList()) ;
}
return false;
}
but the above call is failing. In eclipse debugger it is showing same
values and size for both the lists but myKey.getList() has different
modCount than myList.
I have overridden hashcode method too. Am i missing something above?
Thanks.
On Wed, Nov 28, 2012 at 7:58 AM, Brock Noland <br...@cloudera.com> wrote:
> What are you using for output Key? Is it a custom writable?
>
>
> On Tue, Nov 27, 2012 at 11:14 PM, Dipesh Khakhkhar <
> dipeshsoftware@gmail.com> wrote:
>
>> I'm using MRUnit to test my M/R classes.
>>
>> My mapper is simple one
>>
>> - It takes input file with input like
>> 1
>> 2
>> 3
>>
>> - Its outputs is
>> Key 0,0,0
>> Value 1,
>>
>> key 0,0,1
>> Value 2,
>>
>> Now I am using MRUnit to test my mapper with following input and expected
>> output -
>>
>> Input: "1"
>> Expected Output: like this mapDriver.withOutput(key, new Text("1,") ); //
>> where my key is 0,0,0
>>
>> I'm getting following error
>>
>> java.lang.AssertionError: 2 Error(s): (Missing expected output (0,0,0,,
>> 1,) at position 0., Received unexpected output (0,0,0,, 1,) at position 0.)
>>
>> It seems to me my output is correct (lhs==rhs) - am i missing something
>> above? Please correct me if I'm wrong.
>>
>> Thanks in advance for replying and answering my query.
>>
>> Thanks.
>>
>>
>
>
> --
> Apache MRUnit - Unit testing MapReduce -
> http://incubator.apache.org/mrunit/
>
Re: Mapper unit test failing - validation failing
Posted by Brock Noland <br...@cloudera.com>.
What are you using for output Key? Is it a custom writable?
On Tue, Nov 27, 2012 at 11:14 PM, Dipesh Khakhkhar <dipeshsoftware@gmail.com
> wrote:
> I'm using MRUnit to test my M/R classes.
>
> My mapper is simple one
>
> - It takes input file with input like
> 1
> 2
> 3
>
> - Its outputs is
> Key 0,0,0
> Value 1,
>
> key 0,0,1
> Value 2,
>
> Now I am using MRUnit to test my mapper with following input and expected
> output -
>
> Input: "1"
> Expected Output: like this mapDriver.withOutput(key, new Text("1,") ); //
> where my key is 0,0,0
>
> I'm getting following error
>
> java.lang.AssertionError: 2 Error(s): (Missing expected output (0,0,0,,
> 1,) at position 0., Received unexpected output (0,0,0,, 1,) at position 0.)
>
> It seems to me my output is correct (lhs==rhs) - am i missing something
> above? Please correct me if I'm wrong.
>
> Thanks in advance for replying and answering my query.
>
> Thanks.
>
>
--
Apache MRUnit - Unit testing MapReduce - http://incubator.apache.org/mrunit/