Return-Path: X-Original-To: apmail-hadoop-common-dev-archive@www.apache.org Delivered-To: apmail-hadoop-common-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3ABB2106BF for ; Thu, 31 Oct 2013 11:03:50 +0000 (UTC) Received: (qmail 27244 invoked by uid 500); 31 Oct 2013 11:03:38 -0000 Delivered-To: apmail-hadoop-common-dev-archive@hadoop.apache.org Received: (qmail 27177 invoked by uid 500); 31 Oct 2013 11:03:38 -0000 Mailing-List: contact common-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-dev@hadoop.apache.org Received: (qmail 27158 invoked by uid 99); 31 Oct 2013 11:03:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Oct 2013 11:03:35 +0000 X-ASF-Spam-Status: No, hits=2.7 required=5.0 tests=HTML_MESSAGE,HTML_OBFUSCATE_10_20,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of unmeshabiju@gmail.com designates 209.85.128.179 as permitted sender) Received: from [209.85.128.179] (HELO mail-ve0-f179.google.com) (209.85.128.179) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Oct 2013 11:03:28 +0000 Received: by mail-ve0-f179.google.com with SMTP id cz12so1929475veb.38 for ; Thu, 31 Oct 2013 04:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ZbQ44FbksM9WV/Rg812xltmAhvNcKrnqbCI+uuUg7C4=; b=wRZc+bcSVDGMksISo/0qNE/GoiK62emT8W1JhxqjJko+DgISK3u4Wn5VlQatMCaDli zGZZ5srUbZIPxsBVh475YhMbqNuvqzY/9LyzT0esaw9I8GBI2CAOLnbMWYx8OGMlJjkP +3QjmfQ5MfHGyy9TLGBADk4pYQ+k6dh99GcLD5X2a30ddARtCcZ14QUvPEILPP4xWDvW MbfFpH/ZHuHacOWiGK0C2ilNMy3/7W2E5xRC88hg5AUWkTPV31zSKvsbfQkznw+iRO+I SaUiJLjs8a/VTCr2ilOdwck6PcMGpT47k3zZchscGAG0blkP5cjTjiK8iUYDhLND9YjA QS7Q== MIME-Version: 1.0 X-Received: by 10.221.27.73 with SMTP id rp9mr1458553vcb.29.1383217387351; Thu, 31 Oct 2013 04:03:07 -0700 (PDT) Received: by 10.59.8.2 with HTTP; Thu, 31 Oct 2013 04:03:07 -0700 (PDT) Date: Thu, 31 Oct 2013 16:33:07 +0530 Message-ID: Subject: Implementing a custom hadoop key and value - need Help From: unmesha sreeveni To: Common Hadoop , General Hadoop , User Hadoop Content-Type: multipart/alternative; boundary=001a113397060534f704ea076523 X-Virus-Checked: Checked by ClamAV on apache.org --001a113397060534f704ea076523 Content-Type: text/plain; charset=ISO-8859-1 this is my post from stackoverflow but i am not getting any response. I need to emit a 2D double array as key and value from mapper.There are questions posted in stackoverflow. But they are not answered. we have to create a custom datatype.but how?I am new to these custom datatypes. i dnt have any idea where to start.I am doing some of the matrix multiplication in a given dataset.and after that i need to emit the value of A*Atrns which will be a matrix and Atrans*D which will also be a matrix.so how to emit these matrices from mapper.And the value should be corresponding to the key itself.I think for that we need to use WritableComparable. public class MatrixWritable implements WritableComparable{ /** * @param args */ private double[][] value; public MatrixWritable() { // TODO Auto-generated constructor stub set(new double[0][0]); } public MatrixWritable(double[][] value) { // TODO Auto-generated constructor stub this.value = value; } 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 col=0; for(int i=0; i { public void reduce(Iterable key, Iterable values, Context context){ for(MatrixWritable c : values){ System.out.println("print value "+c.toString()); } } but Nothing is printing.when i tried to print value[0].length in toString() method it showsArrayIndexOutOfBoundExcep.Am i doing any thing wrong.and i also needed to print my data asmatrix so i tried public String toString() { String separator = ", "; StringBuffer result = new StringBuffer(); // iterate over the first dimension for (int i = 0; i < value.length; i++) { // iterate over the second dimension for(int j = 0; j < value[i].length; j++){ result.append(value[i][j]); System.out.print(value[i][j]); result.append(separator); } // remove the last separator result.setLength(result.length() - separator.length()); // add a line break. result.append("\n"); } return result.toString(); } Again my output is empty. 3.Inorder to emit a key too as custom datatype CompareTo is neccessary right . 4.so what should i include in that methods CompareTo,hashcode,equals and what are these methods intended for. Any Idea.Pls suggest a solution. -- *Thanks & Regards* * * Unmesha Sreeveni U.B* * *Junior Developer * *Amrita Center For Cyber Security * * Amritapuri. www.amrita.edu/cyber/ * --001a113397060534f704ea076523--