Return-Path: Delivered-To: apmail-hadoop-core-user-archive@www.apache.org Received: (qmail 39624 invoked from network); 23 Apr 2008 10:38:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Apr 2008 10:38:19 -0000 Received: (qmail 97257 invoked by uid 500); 23 Apr 2008 10:38:16 -0000 Delivered-To: apmail-hadoop-core-user-archive@hadoop.apache.org Received: (qmail 97230 invoked by uid 500); 23 Apr 2008 10:38:16 -0000 Mailing-List: contact core-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-user@hadoop.apache.org Delivered-To: mailing list core-user@hadoop.apache.org Received: (qmail 97219 invoked by uid 99); 23 Apr 2008 10:38:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Apr 2008 03:38:16 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Apr 2008 10:37:23 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1JocMB-0005UG-R2 for core-user@hadoop.apache.org; Wed, 23 Apr 2008 03:37:43 -0700 Message-ID: <16833976.post@talk.nabble.com> Date: Wed, 23 Apr 2008 03:37:43 -0700 (PDT) From: CloudyEye To: core-user@hadoop.apache.org Subject: Simple SetWritable class MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: suhel77@gmail.com X-Virus-Checked: Checked by ClamAV on apache.org I tried to extend TreeSet to be Wrtiable. Here is what I did. public class SetWritable extends TreeSet implements WritableComparable { public void readFields(DataInput in) throws IOException { clear(); int sz=in.readInt(); for (int i = 0; i < sz; i++) { add(in.readInt()); } } public void write(DataOutput out) throws IOException { out.writeInt(size()); Iterator iter=this.iterator(); while (iter.hasNext()) { out.writeInt(iter.next()); } } } If I remove clear() from the readFields() I am gettting wrong output.(some old data is written with the new ones !). With "clear()" it is ok as my simple tests show. Is this implementaion save to be used ? Regards, -- View this message in context: http://www.nabble.com/Simple-SetWritable-class-tp16833976p16833976.html Sent from the Hadoop core-user mailing list archive at Nabble.com.