Return-Path: X-Original-To: apmail-mahout-user-archive@www.apache.org Delivered-To: apmail-mahout-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4CDA7D2E5 for ; Wed, 19 Dec 2012 02:00:49 +0000 (UTC) Received: (qmail 38359 invoked by uid 500); 19 Dec 2012 02:00:47 -0000 Delivered-To: apmail-mahout-user-archive@mahout.apache.org Received: (qmail 38321 invoked by uid 500); 19 Dec 2012 02:00:47 -0000 Mailing-List: contact user-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@mahout.apache.org Delivered-To: mailing list user@mahout.apache.org Received: (qmail 38312 invoked by uid 99); 19 Dec 2012 02:00:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 02:00:47 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.223.175 as permitted sender) Received: from [209.85.223.175] (HELO mail-ie0-f175.google.com) (209.85.223.175) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 02:00:41 +0000 Received: by mail-ie0-f175.google.com with SMTP id qd14so1926416ieb.20 for ; Tue, 18 Dec 2012 18:00:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=XBLG/rtw63bQoLUpjmb8l2TtedgTtegwrGCWR2Qu/kE=; b=tO821B5aeZKAmdTd83YO38m00kVyEe9tKsdu5rqz3Y1wLJaf+gDMmmgymD1MncZUfs fZXtC1XSWmD7nbBGXN83sghbZnw6HBrn/KGVaiOgHJ64KASyJ8WTNgksYWoDgAS06Y6q SKHHSxN4219wdhRNESChMHtWO1r3AQrCtxb3jM2CX/0ewlxymXbSi0AQwUNyKgIn4qwe Zq4iB2XIk7RTl8juiNqVwBna+tuvUSyb0R0x0G7DqdTRFKoEyWvBaM5nacer4PRLQuzF TH0A17RFwSHxOcCMOiX8idDb+oEp8qvdCF4Qk7wDzJp3Ff4j9b+P6/QQV3KfEXkDUc5J idtw== Received: by 10.50.193.234 with SMTP id hr10mr5185112igc.21.1355882420484; Tue, 18 Dec 2012 18:00:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.97.106 with HTTP; Tue, 18 Dec 2012 17:59:50 -0800 (PST) In-Reply-To: <2433CB12-59AB-4A5C-9909-90526219F698@gmail.com> References: <2433CB12-59AB-4A5C-9909-90526219F698@gmail.com> From: Ted Dunning Date: Tue, 18 Dec 2012 17:59:50 -0800 Message-ID: Subject: Re: Is there anyway you could easily make a deep copy of Vector Writable class with hadoop's ReflectionUtils? To: user@mahout.apache.org Content-Type: multipart/alternative; boundary=14dae934069f07bbb604d12afa78 X-Virus-Checked: Checked by ClamAV on apache.org --14dae934069f07bbb604d12afa78 Content-Type: text/plain; charset=UTF-8 You can always just call clone() on the vector inside the VectorWritable. On Tue, Dec 18, 2012 at 5:49 PM, Yunming Zhang wrote: > Hi, > > I have been trying to find a way to make a deep copy of key, value pairs > inside SequenceFileRecordReader as I am implementing a getCurrentKeyCopy() > and getCurrentValueCopy() method, but I am getting null pointer exception > when calling "value.get()" in CIMapper.java, line 37, > > I want the record reader to create a new data object for the new key value > pairs instead of reusing the original memory location, > > I found a few utility classes in Hadoop that should be able to make a deep > copy or clone any writable class, > > key = ReflectionUtils.copy(outer.getConfiguration(), > outer.getCurrentKey(), key); > value = ReflectionUtils.copy(conf, outer.getCurrentValue(), value); > > from MultiThreadedMapper and there is also WritableUtils.clone(...) method, > > However, both approaches seems to be failing for VectorWritable, I did > notice that it is a bit different in that it wraps around another Mahout > type, Vector, instead of a primitive type like int, long or string, in the > cases of IntWritable and all that, > > I am not sure if this is why the copy or clone utilities in Hadoop > designed for Writable is not working ? > > Currently it is giving me null pointer exception when I try to call > value.get(), it does seem we copied something, but the vector inside > VectorWritable might have failed to get copied, > > Thanks > > Yunming --14dae934069f07bbb604d12afa78--