Return-Path: X-Original-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 664E7105A1 for ; Tue, 27 Aug 2013 15:57:45 +0000 (UTC) Received: (qmail 71605 invoked by uid 500); 27 Aug 2013 15:57:38 -0000 Delivered-To: apmail-hadoop-mapreduce-user-archive@hadoop.apache.org Received: (qmail 71511 invoked by uid 500); 27 Aug 2013 15:57:37 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 71504 invoked by uid 99); 27 Aug 2013 15:57:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Aug 2013 15:57:37 +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 shahab.yunus@gmail.com designates 209.85.214.45 as permitted sender) Received: from [209.85.214.45] (HELO mail-bk0-f45.google.com) (209.85.214.45) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Aug 2013 15:57:33 +0000 Received: by mail-bk0-f45.google.com with SMTP id mx11so1666598bkb.18 for ; Tue, 27 Aug 2013 08:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dqzAZFvRPg5QERnlQtBRJmhVbiv7HxVy343dVm7XVfY=; b=Kzn4zVA8IdY5T7SCI+Q9LwfqKVjJKSD0TJnXbLxmg9g+7Om0g+YddmXfBMQC14NcPU E1M+zmGODPVEGptCfruX1SN/LaPuaLnO6/yn2HawcRDT0NhF09JIKV3MDH6F/3tYDbxD BIDQnJFX2jfN6CFmxr8/bjvuDljdwj05tvP9X/T+qssxXHv1SEwGk0ueBBFbGAZXyCCA f5PIkduEY/4yeHSe5tDNN84ZVJtIRzLGulHO57BpuoE8RZQZ42/25fcssaTT5g258B/A iihrOYF1BFR3PBhYiYCvN+/O7rM2urtxPkK0HzLEWANhNZmWG1KibYNrgeQi1sNugNyw Ft9A== MIME-Version: 1.0 X-Received: by 10.204.62.132 with SMTP id x4mr15690934bkh.22.1377619031801; Tue, 27 Aug 2013 08:57:11 -0700 (PDT) Received: by 10.204.231.76 with HTTP; Tue, 27 Aug 2013 08:57:11 -0700 (PDT) In-Reply-To: References: Date: Tue, 27 Aug 2013 11:57:11 -0400 Message-ID: Subject: Re: MapReduce Tutorial tweak From: Shahab Yunus To: "user@hadoop.apache.org" Content-Type: multipart/alternative; boundary=001a11c3916207021e04e4efedc5 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c3916207021e04e4efedc5 Content-Type: text/plain; charset=ISO-8859-1 As far as I undersstand, StringTokenizer.nextToken returns Java String type object which does not implement the required Writable and Comparable interfaces needed to Hadoop Mapreduce serialization and transport. The Text class does that and is compatible and thus that is why that is being used to wrap Java String and pass it on. Regards, Shahab On Tue, Aug 27, 2013 at 11:16 AM, Andrew Pennebaker wrote: > In https://hadoop.apache.org/docs/stable/mapred_tutorial.html#Source+Code, > line 16 declares: > > private Text word = new Text(); > > ... > > But only lines 22 and 23 use this, and only to pass the value along to > output: > > word.set(tokenizer.nextToken()); > output.collect(word, one); > > Wouldn't this be better expressed as: > > (no private Text word) > > ... > > output.collect(tokenizer.nextToken(), one); > > ? > --001a11c3916207021e04e4efedc5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
As far as I undersstand, StringTokenizer.nextToken returns= Java String type object which does not implement the required Writable and= Comparable interfaces needed to Hadoop Mapreduce serialization and transpo= rt. The Text class does that and is compatible and thus that is why that is= being used to wrap Java String and pass it on.

Regards,
Shahab

--001a11c3916207021e04e4efedc5--