You just have to implement the WritableComparable interface. This might be
straight forward for any simple data type. Have look on:
public int compareTo(MyWritableComparable o) {
int thisValue = this.value
int thatValue = o.value;
return (thisValue < thatValue ? 1 : (thisValue==thatValue ? 0 : 1)); ...
But a matrix is something different.
Now its your turn. Find out how to order your matrix objects. This can
be any type of order which makes sense. Maybe the total sum or the
total average of all values or whatever. It has to calc only 1, 0 or
1, depending on the given matrixes. I would assume that 0 will be
given back if all pairs of elements from both matrizes with the same
indexes are equal.
But why do you need the Matrix one as the KEY in your reducer?
Maybe it is better to use Custom object only as the Value, together
with an arbitrary Key, which is WritableComparable ... but this
depends on, what you want to calc in your reducer.
If you share the description of the problem and the algorithm which
solves it, we will find out whats the best way.
What does you algorithm calculate?
Best wishes
Mirko
2013/11/4 unmesha sreeveni <unmeshabiju@gmail.com>
> I am trying to emit a matrix(2D double array) as key and another matrix as
> value.
>
> ie context.write(new myclass(matrixa),new myclass(matrixb));
> * so how to compare them
>
>
> On Mon, Nov 4, 2013 at 4:16 PM, unmesha sreeveni <unmeshabiju@gmail.com>wrote:
>
>> Thanks Dieter De Witte
>>
>>
>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <drdwitte@gmail.com>wrote:
>>
>>> A writableComparable is an interface. A key in mapreduce needs to
>>> implement it, since the keys need to be compared for equality. So it has
>>> nothing to do with key value pairs as such.
>>>
>>> Regards, Dieter
>>>
>>>
>>> 2013/11/4 unmesha sreeveni <unmeshabiju@gmail.com>
>>>
>>>>
>>>> what is CompateTo() in WritableComparable?
>>>> Is that comparing a key and value or comparing key and key,value and
>>>> value
>>>>
>>>> 
>>>> *Thanks & Regards*
>>>>
>>>> Unmesha Sreeveni U.B
>>>>
>>>> *Junior Developer*
>>>>
>>>> *Amrita Center For Cyber Security *
>>>>
>>>>
>>>> * Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*
>>>>
>>>
>>>
>>
>>
>> 
>> *Thanks & Regards*
>>
>> Unmesha Sreeveni U.B
>>
>> *Junior Developer*
>>
>> *Amrita Center For Cyber Security *
>>
>>
>> * Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*
>>
>
>
>
> 
> *Thanks & Regards*
>
> Unmesha Sreeveni U.B
>
> *Junior Developer*
>
> *Amrita Center For Cyber Security *
>
>
> * Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*
>
