Return-Path: Delivered-To: apmail-hadoop-core-user-archive@www.apache.org Received: (qmail 30385 invoked from network); 19 Aug 2008 20:58:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Aug 2008 20:58:33 -0000 Received: (qmail 95034 invoked by uid 500); 19 Aug 2008 20:58:25 -0000 Delivered-To: apmail-hadoop-core-user-archive@hadoop.apache.org Received: (qmail 94988 invoked by uid 500); 19 Aug 2008 20:58:25 -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 94977 invoked by uid 99); 19 Aug 2008 20:58:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Aug 2008 13:58:25 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of snickerdoodle08@gmail.com designates 209.85.217.13 as permitted sender) Received: from [209.85.217.13] (HELO mail-gx0-f13.google.com) (209.85.217.13) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Aug 2008 20:57:29 +0000 Received: by gxk6 with SMTP id 6so5333187gxk.5 for ; Tue, 19 Aug 2008 13:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=W0f3kM95SmW8eMFO0sOynj0RT7VIJiOE8UTSlNxtPig=; b=QQHwyiEkTPIMMwQ/oOiTWD2P5YoZ7SKApFszgA4jxZgn/RlYOllz3tCn6SRzWULh+U 7BzRQj7n1k48sA9Ob9ABE4XrO5z+K8/xgYZLp9m6tTSWkZmtT3IoPFI1qKTTo1XjQTjR ujsta82fkYJ9Lw4dW+E1Mh9XnPYJoY2OIPcdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=cw32IFNHXnpSCudvvLgjQMxZo7NNwzcq/2CGI6AJFCxMVJujHaym1yKRrY75ZchxU3 jqdFrNLfgfTGqLGY1fWH3wn1OW6femK/93h/AiSefTX6jjyT7704stiisf8vj903oqr4 SmaILpjhCtYUdlVO2j+myl+easiF7AyJXqQgQ= Received: by 10.151.42.10 with SMTP id u10mr940719ybj.49.1219179417438; Tue, 19 Aug 2008 13:56:57 -0700 (PDT) Received: by 10.150.134.2 with HTTP; Tue, 19 Aug 2008 13:56:57 -0700 (PDT) Message-ID: <257c70550808191356u68f00821g655af38a694aea17@mail.gmail.com> Date: Tue, 19 Aug 2008 15:56:57 -0500 From: Sandy To: core-user@hadoop.apache.org Subject: pseudo-global variable constuction MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12661_11319380.1219179417295" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_12661_11319380.1219179417295 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, My M/R program is going smoothly, except for one small problem. I have a "global" variable that is set by the user (and thus in the main function), that I want one of my reduce functions to access. This is a read-only variable. After some reading in the forums, I tried something like this: file: MyGlobalVars.java package org.apache.hadoop.examples; public class MyGlobalVars { static public int nTax; } ------ file: myLittleMRProgram.java package.org.apache.hadoop.examples; map function() { System.out.println("in map function, nTax is: " + MyGlobalVars.nTax); } .... main() { MyGlobalVars.nTax = other_args.get(2); System.out.println("in main function, nTax is: " + MyGlobalVars.nTax); .... JobClient.runJob(conf); .... return 0; } -------- When I run it, I get: in main function, nTax is 20 (which is what I want) in map function, nTax is 0 (<--- this is not right). I am a little confused on how to resolve this. I apologize in advance if this is an blatant java error; I only began programming in the language a few weeks ago. Since Map Reduce tries to avoid the whole shared-memory scene, I am more than willing to have each reduce function receive a local copy of this user defined value. However, I am a little confused on what the best way to do this would be. As I see it, my options are: 1.) write the user defined value to the hdfs in the main function, and have it read from the hdfs in the reduce function. I can't quite figure out the code to this though. I know how to specify -an- input file for the map reduce task, but if I did it this way, won't I need to specify two separate input files? 2. Put it in the construction of the reduce object (I saw this mentioned in the archives). How would I accomplish this exactly when the value is user defined? Parameter Passing? If so, won't this require me changing the underlying map reduce base (which makes me a touch nervous, since i'm still very new to hadoop). What would be the easiest way to do this? Thanks in advance for the help. I appreciate your time. -SM ------=_Part_12661_11319380.1219179417295--