Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Hadoop >> mail # dev >> Re: Empty value in write() method : Custom Datatype in Hadoop MapReduce


Copy link to this message
-
Re: Empty value in write() method : Custom Datatype in Hadoop MapReduce
Empty value in write() method : Custom Datatype in Hadoop MapReduce[Solved]
On Wed, Oct 30, 2013 at 11:23 AM, unmesha sreeveni <[EMAIL PROTECTED]>wrote:

> I am emiting two 2D double array as key and value.I am in construction of
> my WritableComparable class.
>
>
> *public class MF implements WritableComparable<MF>{
> /**
>  * @param args
>  */private double[][] value;
> public MF() {
>     // TODO Auto-generated constructor stub
> }
>   public MF(double[][] value) {
>     // TODO Auto-generated constructor stub
>
>       this.value = new double[value.length][value[0].length];
>     // System.out.println("in matrix");}
>  public void set(double[][] value) {
>       this.value = value;
>   }
>  public double[][] getValue() {
>         return value;
>       }
>
>  @Override
>   public void write(DataOutput out) throws IOException {
>      System.out.println("write");
>      int row=0;
>         int column=0;
>         for(int i=0; i<value.length;i++){
>             row = value.length;
>             for(int j=0; j<value[i].length; j++){
>                 column = value[i].length;
>             }
>         }
>         out.writeInt(row);
>         out.writeInt(column);
>
>
>
>         for(int i=0;i<value.length ; i++){
>             for(int j= 0 ; j< value[0].length;j++){
>                  out.writeDouble(value[i][j]);
>                 }
>         }
>         for(int i =0;i< value.length ;i ++){
>             for(int j = 0;j <value[0].length;j++){
>                 System.out.print(value[i][j]+ "\t");
>             }
>             System.out.println("");
>         }
>
>   }
>
>   @Override
>   public void readFields(DataInput in) throws IOException {
>       int row = in.readInt();
>       int col = in.readInt();
>
>
>       double[][] value = new double[row][col];
>       for(int i=0;i<row ; i++){
>             for(int j= 0 ; j< col;j++){
>                 value[i][j] = in.readDouble();
>
>             }
>         }
>   }
>
>   @Override
>   public int hashCode() {
>
>   }
>
>   @Override
>   public boolean equals(Object o) {
>
>   }
>
> @Overridepublic int compareTo(MF o) {
>     // TODO Auto-generated method stub
>     return 0;}
>  @Override
>   public String toString() {
>      System.out.println(Arrays.toString(value));
>     return Arrays.toString(value);
>
>   }*
>
> *}*
>
> And by half of the way...when i tried to print my matrix within write
> method,the matrix is not having values
>
>
>   write
>
> 0.0 0.0 0.0
> 0.0 0.0 0.0
> 0.0 0.0 0.0
>
>
>   write
>
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
>
>
> I am doing something wrong. Can anyone help me out to resolve this.I am
> getting apt no of rows and col.
>
> --
> *Thanks & Regards*
> *
> *
> Unmesha Sreeveni U.B*
> *
>
> **
>

--
*Thanks & Regards*
*
*
Unmesha Sreeveni U.B*
*
*Junior Developer
*
*Amrita Center For Cyber Security
*
*
Amritapuri.

www.amrita.edu/cyber/
*
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB