You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by unmesha sreeveni <un...@gmail.com> on 2013/11/04 11:29:59 UTC

CompateTo() in WritableComparable

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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
ie key ----->  A*Atrans--------->after multiplication the result will
be a 2D array which is declared as double (matrix) lets say the result
be Matrix "Ekey"(double[][] Ekey)

value ------>  Atrans*D ---------> after multiplication the result
will be Matrix "Eval" (double[][] Eval).

After tat i need to emit these matrix to reducer for further calculations.

so in mapper
       context.write(Ekey,Eval);

reducer
      i need to do further calculations with these Ekey nd Eval.ie
calculate (I/v + Ekey)*Eval. where I/v is a matrix with order of Ekey

public int compareTo(MatrixWritable o) {
    // TODO Auto-generated method stub
		
		boolean ret = Arrays.equals(values, o.values);
		
		
	
		

	}

I am really confused what to check, as i dnt get a complete idea of
compareTo() while relating it to mapreduce.

my input will be a file wit numerical data  say 'A' . from that i am
calculating Ekey and Eval in mapper.

                    context.write(new MatrixWritable(Ekey),new
MatrixWritable(Eval));

so what to compare. whether keys?if same key is coming...some thing
like that or?




On Mon, Nov 4, 2013 at 5:07 PM, Mirko Kämpf <mi...@gmail.com> wrote:

> 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 <un...@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 <un...@gmail.com>wrote:
>>
>>> Thanks Dieter De Witte
>>>
>>>
>>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>>
>
>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*

*Amrita Center For Cyber Security*


* Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
ie key ----->  A*Atrans--------->after multiplication the result will
be a 2D array which is declared as double (matrix) lets say the result
be Matrix "Ekey"(double[][] Ekey)

value ------>  Atrans*D ---------> after multiplication the result
will be Matrix "Eval" (double[][] Eval).

After tat i need to emit these matrix to reducer for further calculations.

so in mapper
       context.write(Ekey,Eval);

reducer
      i need to do further calculations with these Ekey nd Eval.ie
calculate (I/v + Ekey)*Eval. where I/v is a matrix with order of Ekey

public int compareTo(MatrixWritable o) {
    // TODO Auto-generated method stub
		
		boolean ret = Arrays.equals(values, o.values);
		
		
	
		

	}

I am really confused what to check, as i dnt get a complete idea of
compareTo() while relating it to mapreduce.

my input will be a file wit numerical data  say 'A' . from that i am
calculating Ekey and Eval in mapper.

                    context.write(new MatrixWritable(Ekey),new
MatrixWritable(Eval));

so what to compare. whether keys?if same key is coming...some thing
like that or?




On Mon, Nov 4, 2013 at 5:07 PM, Mirko Kämpf <mi...@gmail.com> wrote:

> 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 <un...@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 <un...@gmail.com>wrote:
>>
>>> Thanks Dieter De Witte
>>>
>>>
>>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>>
>
>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*

*Amrita Center For Cyber Security*


* Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
ie key ----->  A*Atrans--------->after multiplication the result will
be a 2D array which is declared as double (matrix) lets say the result
be Matrix "Ekey"(double[][] Ekey)

value ------>  Atrans*D ---------> after multiplication the result
will be Matrix "Eval" (double[][] Eval).

After tat i need to emit these matrix to reducer for further calculations.

so in mapper
       context.write(Ekey,Eval);

reducer
      i need to do further calculations with these Ekey nd Eval.ie
calculate (I/v + Ekey)*Eval. where I/v is a matrix with order of Ekey

public int compareTo(MatrixWritable o) {
    // TODO Auto-generated method stub
		
		boolean ret = Arrays.equals(values, o.values);
		
		
	
		

	}

I am really confused what to check, as i dnt get a complete idea of
compareTo() while relating it to mapreduce.

my input will be a file wit numerical data  say 'A' . from that i am
calculating Ekey and Eval in mapper.

                    context.write(new MatrixWritable(Ekey),new
MatrixWritable(Eval));

so what to compare. whether keys?if same key is coming...some thing
like that or?




On Mon, Nov 4, 2013 at 5:07 PM, Mirko Kämpf <mi...@gmail.com> wrote:

> 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 <un...@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 <un...@gmail.com>wrote:
>>
>>> Thanks Dieter De Witte
>>>
>>>
>>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>>
>
>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*

*Amrita Center For Cyber Security*


* Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
ie key ----->  A*Atrans--------->after multiplication the result will
be a 2D array which is declared as double (matrix) lets say the result
be Matrix "Ekey"(double[][] Ekey)

value ------>  Atrans*D ---------> after multiplication the result
will be Matrix "Eval" (double[][] Eval).

After tat i need to emit these matrix to reducer for further calculations.

so in mapper
       context.write(Ekey,Eval);

reducer
      i need to do further calculations with these Ekey nd Eval.ie
calculate (I/v + Ekey)*Eval. where I/v is a matrix with order of Ekey

public int compareTo(MatrixWritable o) {
    // TODO Auto-generated method stub
		
		boolean ret = Arrays.equals(values, o.values);
		
		
	
		

	}

I am really confused what to check, as i dnt get a complete idea of
compareTo() while relating it to mapreduce.

my input will be a file wit numerical data  say 'A' . from that i am
calculating Ekey and Eval in mapper.

                    context.write(new MatrixWritable(Ekey),new
MatrixWritable(Eval));

so what to compare. whether keys?if same key is coming...some thing
like that or?




On Mon, Nov 4, 2013 at 5:07 PM, Mirko Kämpf <mi...@gmail.com> wrote:

> 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 <un...@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 <un...@gmail.com>wrote:
>>
>>> Thanks Dieter De Witte
>>>
>>>
>>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>>
>
>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*

*Amrita Center For Cyber Security*


* Amritapuri.www.amrita.edu/cyber/ <http://www.amrita.edu/cyber/>*

Re: CompateTo() in WritableComparable

Posted by Mirko Kämpf <mi...@gmail.com>.
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 <un...@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 <un...@gmail.com>wrote:
>
>> Thanks Dieter De Witte
>>
>>
>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by Mirko Kämpf <mi...@gmail.com>.
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 <un...@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 <un...@gmail.com>wrote:
>
>> Thanks Dieter De Witte
>>
>>
>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by Mirko Kämpf <mi...@gmail.com>.
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 <un...@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 <un...@gmail.com>wrote:
>
>> Thanks Dieter De Witte
>>
>>
>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by Mirko Kämpf <mi...@gmail.com>.
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 <un...@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 <un...@gmail.com>wrote:
>
>> Thanks Dieter De Witte
>>
>>
>> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@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 <un...@gmail.com>wrote:

> Thanks Dieter De Witte
>
>
> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@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 <un...@gmail.com>wrote:

> Thanks Dieter De Witte
>
>
> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@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 <un...@gmail.com>wrote:

> Thanks Dieter De Witte
>
>
> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@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 <un...@gmail.com>wrote:

> Thanks Dieter De Witte
>
>
> On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
Thanks Dieter De Witte


On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
Thanks Dieter De Witte


On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
Thanks Dieter De Witte


On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by unmesha sreeveni <un...@gmail.com>.
Thanks Dieter De Witte


On Mon, Nov 4, 2013 at 4:11 PM, Dieter De Witte <dr...@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 <un...@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/>*

Re: CompateTo() in WritableComparable

Posted by Dieter De Witte <dr...@gmail.com>.
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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by Dieter De Witte <dr...@gmail.com>.
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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by Dieter De Witte <dr...@gmail.com>.
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 <un...@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/>*
>

Re: CompateTo() in WritableComparable

Posted by Dieter De Witte <dr...@gmail.com>.
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 <un...@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/>*
>