hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Evans <ev...@yahoo-inc.com>
Subject Re: On the relationship between MultithreadedMapper and tasks
Date Mon, 07 Nov 2011 16:26:09 GMT
What you are doing is commonly called a map/side join.  You can often improve your performance
by increasing the replication count for the smaller files, 10 is usually a good number, but
you can play around with it, and by bringing them in using the distributed cache instead of
reading them directly from HDFS.

To answer your original question what I would suggest you do is to have a synchronized static
method dot he setup.

Public class ...
    private static boolean dataHasBeenRead = false
    private static synchronized void internalSetup(...) {
        if(!dataHasBeenRead) {
            //Read the data
            dataHasBeenRead = true;

You can then call this from your original setup method, or you can switch to something like
pig that handles all of this for you behind the scenes.

--Bobby Evans

On 11/5/11 11:47 AM, "Claudio Martella" <claudio.martella@tis.bz.it> wrote:

Hello list,

I have a task where I have compare the entries of a big sequencefile
with the entries of many small sequencefiles.

Basically you could describe it like this:

for entry in bigSequenceFile:
    for file in listOfSmallFiles:
        for entry2 in file:
            compare(entry, entry2)

My approach is to use a map-only job. I put the big file in HDFS in the
directory which will be the inputPath for the job and the small files in
HDFS in another directory.
Then in my mapper I will load all the small files in memory and will
compare them to the records which will be sent to me in map() from the
big file.

Something like this:

map(key, value):
    for list in smallFiles:
        for entry in list:
            compare(value, entry)

As I don't want, on each node, to load the files multiple times wasting
memory, I thought about using a MultithreadedMapper, load the my small
files at setup() (ideally called once at the instantiation of the
object) into a datastructure (i.e. a LinkedList, smallFiles in the
pseudocode) shared between the threads.

So basically each node would create only one task with more threads each
running on one CPU and sharing the in-memory datastructure.

The problem I'm facing is that for each thread the setup() method is
called once (so #threads times in total), which is not what I want as it
will load the smallFiles multiple times on a shared datastructure.

Also I'm afraid I'm not able to control the number of these
MultithreadedMappers ran on each node (I want only one).

Can anybody help me out understanding how I can leverage
MultithreadedMapper to get what I want (there's very little info on the
internet about MultithreadedMapper)?


Claudio Martella
Free Software & Open Technologies

TIS innovation park
Via Siemens 19 | Siemensstr. 19
39100 Bolzano | 39100 Bozen
Tel. +39 0471 068 123
Fax  +39 0471 068 129
claudio.martella@tis.bz.it http://www.tis.bz.it

Short information regarding use of personal data. According to Section 13 of Italian Legislative
Decree no. 196 of 30 June 2003, we inform you that we process your personal data in order
to fulfil contractual and fiscal obligations and also to send you information regarding our
services and events. Your personal data are processed with and without electronic means and
by respecting data subjects' rights, fundamental freedoms and dignity, particularly with regard
to confidentiality, personal identity and the right to personal data protection. At any time
and without formalities you can write an e-mail to privacy@tis.bz.it in order to object the
processing of your personal data for the purpose of sending advertising materials and also
to exercise the right to access personal data and other rights referred to in Section 7 of
Decree 196/2003. The data controller is TIS Techno Innovation Alto Adige, Siemens Street n.
19, Bolzano. You can find the complete information on the web site www.tis.bz.it.

View raw message