Dec 27, 2009

A WordCount Tutorial for Hadoop 0.20.1

Because the document of Hadoop 0.20.1 describes a tutorial program which uses out-of-date APIs, I decided to write the following tutorial for Hadoop 0.20.1. It is notable that in 0.20.1, org.apache.hadoop.mapred.* are deprecated and it is recommended to use org.apache.hadoop.mapreduce.*. This tutorial is based on the new API.

For how to install and configure Hadoop, you might want to refer to my previous post. After Hadoop is installed, let us create a source code directory and put the following Java source file:
package org.sogou;

import java.io.IOException;
import java.lang.InterruptedException;
import java.util.StringTokenizer;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;

public class WordCount {
/**
* The map class of WordCount.
*/

public static class TokenCounterMapper
extends Mapper<Object, Text, Text, IntWritable> {

private final static IntWritable one = new IntWritable(1);
private Text word = new Text();

public void map(Object key, Text value, Context context)
throws IOException, InterruptedException {
StringTokenizer itr = new StringTokenizer(value.toString());
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
}
}
}
/**
* The reducer class of WordCount
*/

public static class TokenCounterReducer
extends Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable value : values) {
sum += value.get();
}
context.write(key, new IntWritable(sum));
}
}
/**
* The main entry point.
*/

public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
Job job = new Job(conf, "Example Hadoop 0.20.1 WordCount");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenCounterMapper.class);
job.setReducerClass(TokenCounterReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
Then, we build this file and pack the result into a jar file:
mkdir classes
javac -classpath /Users/wyi/hadoop-0.20.1/hadoop-0.20.1-core.jar:/Users/wyi/hadoop-0.20.1//lib/commons-cli-1.2.jar -d classes WordCount.java && jar -cvf wordcount.jar -C classes/ .
Finally, we run the jar file in standalone mode of Hadoop
echo "hello world bye world" > /Users/wyi/tmp/in/0.txt
echo "hello hadoop goodebye hadoop" > /Users/wyi/tmp/in/1.txt
hadoop jar wordcount.jar org.sogou.WordCount /Users/wyi/tmp/in /Users/wyi/tmp/out

271 comments:

«Oldest   ‹Older   201 – 271 of 271
kamini kapoor said...

Nice BLOG!!
Robotics training in chennai
Internship for cse students in chennai
iot internship in chennai
Kaashiv infotech in bangalore
Free internship in chennai for mechanical engineering students
Inplant training
ECE internship in chennai
Internship for cse students in bangalore
Free internship for cse students in chennai
Internship for eee students in chennai

Anand Shankar said...

I think this is an informative post and it is very beneficial and knowledgeable. Therefore, I would like to thank you for the endeavors that you have made in writing this article. All the content is absolutely well-researched.
Visit Giant Brand Solutions
wordpress bundle
wordpress themes and plugins
premium wordpress themes and plugins
wp starter pack
wordpress theme update
wordpress update plugins
wordpress website themes
worpdress theme sites
wordpressbundle
wpstarterpack

python training in vijayawada said...

We as a team of real-time industrial experience with a lot of knowledge in developing applications in python programming (7+ years) will ensure that we will deliver our best in python training in vijayawada. , and we believe that no one matches us in this context.

arun said...

good nice
iot training in chennai
internship for mca students in chennai
internships for cse 3rd year students in hyderabad
information technology projects list 2018
ethical hacking course in chennai
ece internships in bangalore
internship for computer science students
internships in chennai for cse students
internship in chennai for cse 2019
internship for ece students in bangalore

Durai Moorthy said...

Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.

aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

arun said...

GOOD
iot training in chennai
internship for mca students in chennai
internships for cse 3rd year students in hyderabad
information technology projects list 2018
ethical hacking course in chennai
ece internships in bangalore
internship for computer science students
internships in chennai for cse students
internship in chennai for cse 2019
internship for ece students in bangalore

Durai Moorthy said...

Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore

Beast Viral said...

i like your website 파워볼사이트

Online Training Course said...

Microsoft Windows Azure Training in Noida
This is a very well written article. I will be sure to bookmark it and come back to read more of your useful information.

Unknown said...

Thank you for the Article Submission. have a great experenced from this content

RPA Training in Hyderabad | RPA Online Training

Digital Marketing Course in Hyderabad


Pega Training in Hyderabad

AWS Training in Hyderabad

Digital Marketing Course in Hyderabad

Realtime Experts said...

Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge.

sap hr courses in bangalore

sap hr classes in bangalore

sap hr training institute in bangalore

sap hr course syllabus

best sap hr training

sap hr training centers

sap hr training in bangalore

IICT said...

Superb stuff.
SAP Training in Chennai

steffan said...


QuickBooks Error 9999 can occur while you are installing a program or Intuit Inc. related software program (e.g. QuickBooks) is running. Also, it might occur to take place during Windows startup or shutdown, and even if the Windows operating system will be installed.

Deepa said...

It is useful and learned a lot from your post. Salesforce Training Sydney

Unknown said...

Structured Cabling Service in Dubai - Techsquad

We have structured cabling service provider company in Dubai, we provide services like fiber optics installation across Dubai ,our engineers have 10 plus year of experience,
We provide services for IP Telephony PABX Solutions ,Telephone wiring, Data Networking/Switching Solutions
We provide free estimate and free site visit across dubai, our engineers have multiple projects experience,
We also provide lan
cable installation across Dubai for small,medium, and large enterprises,


Dance Classes in Noida 50 - Indrayu Academy said...


zumba classes in Noida

Gurvinder sir said...

Thank your valuable content.we are very thankful to you.one of the recommended blog.which is very useful to new learners and professionals.content is very useful for hadoop learners
how to download ccc admit card 2020

svrtechnologies said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing....

abinitio training

Jack sparrow said...


This post is really nice and informative. The explanation given is really comprehensive and informative.I want some information regarding microsoft office suites training and microsoft 365 tutorial .Thank you. expecting more articles from you .

Jack sparrow said...
This comment has been removed by the author.
svrtechnologies said...

This post is really nice and informative. The explanation given is really comprehensive and useful. learn data science

Urban Dezire Official said...

Hey Nice Blog Post Please Check Out This Link for purchase
https://www.urbandezire.com/product/handmade-leather-messenger-bag/ for your loved ones.

IICT Technologies said...

Amazing Article...

SAP Training in Chennai
Java Training in Chennai
CCNA Training in Chennai
Pearson Vue Exam Center in Chennai
QTP Training in Chennai
Selenium Training in Chennai
Hardware and Networking Training in Chennai
SAP ABAP Training in Chennai
SAP FICO Training in Chennai
AWS Training in Chennai

IT Software Training Institute said...


Machine Learning Course in Bangalore with 100% placement. We are the Best Machine Learning Course Institute in Bangalore. Our Machine Learning course and Certification courses are taught by working professionals who are experts in Machine Learning .

Machine Learning Training in Bangalore

Machine Learning course in bangalore

Machine Learning in bangalore

Machine Learning classes in bangalore

Machine Learning course institute in bangalore

Machine Learning course and Certification course syllabus

best Machine Learning course

Machine Learning course centers

nowfirstviral said...

In the event that you hire our service, you may be receiving the most effective solution. We're going to assure you due to the error-free service 슬롯사이트.

Anonymous said...


Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
welcome to akilmanati
akilmanati

nowfirstviral said...

Very nicely done. Your show schedule gave me the info on some shows I was wondering about. I visited your web site today and found it very interesting and well done 파워볼사이트

Indhu said...

Thanks for sharing this nice informations.
python course in coimbatore

data science course in coimbatore

android training institutes in coimbatore

amazon web services training in coimbatore

big data training in coimbatore

RPA Course in coimbatore

artificial intelligence training in coimbatore

Arvind Kumar said...

Such a very useful information!Thanks for sharing this useful information with us. Really great effort.
Artificial Intelligence Training institute in Bangalore
Artificial Intelligence Training institute in India
Artificial Intelligence Training course
Artificial Intelligence Training in Bangalore

varsha said...

Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
AWS training in chennai | AWS training in anna nagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

Faizal said...

Quite Interesting...i am very impressive to see all the contents...keep it up!!!
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

modelpapers2021 said...

MP Board 12th Class Blueprint 2021 English Medium & Hindi Medium PDF download, MPBSE 12th Blueprint 2021 Pdf Download, mpbse.nic.in 12th Blue Print, Marking Scheme and Arts, Commerce and Science Streams Chapter wise Weightage pdf download. MP Board 12th Blue Print || MPBSE 12th Model Papers || MPBSE 10th Model Papers

Manabadi AP Intermediate 2nd Year Model Question Paper 2021 MPC, BIPC, CEC, MEC group TM, EM Subject wise Blue Print, Download BIEAP Intermediate Second Year Model Question Papers, AP Senior Inter Test Papers, Chapter wise important Questions download. || AP Inter MPC, Bi.PC, CEC Blue Print || AP Inter 1st / 2nd Year Model Papers || AP 2nd year inter Test Papers

Kar 1st / 2nd PUC Blue Print || UP Board 12th Blueprint 2021

merlin said...


Hi, you have given really informative post. Thanks for sharing this post to our vision.
Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery

Training for IT and Software Courses said...

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

sap fico training in bangalore

sap fico class in bangalore

learn sap fico in bangalore

places to learn sap fico in bangalore

sap fico schools in bangalore

sap fico school reviews in bangalore

sap fico training reviews in bangalore

sap fico training in bangalore

sap fico institutes in bangalore

sap fico trainers in bangalore

learning sap fico in bangalore

where to learn sap fico in bangalore

best places to learn sap fico in bangalore

top places to learn sap fico in bangalore

sap fico training in bangalore india

Training for IT and Software Courses said...

After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.

SAP HR Online Training

SAP HR Classes Online

SAP HR Training Online

Online SAP HR Course

SAP HR Course Online

Training for IT and Software Courses said...

I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.

SAP MM Online Training

SAP MM Classes Online

SAP MM Training Online

Online SAP MM Course

SAP MM Course Online

Training for IT and Software Courses said...

Very interesting blog Thank you for sharing such a nice and interesting blog and really very helpful article.

Workday Training in Bangalore

Best Workday Training Institutes in Bangalore

Ishu Sathya said...

wonderful content on A WordCount Tutorial for Hadoop 0.20.1..

Salesforce Training in Chennai

Salesforce Course Online

Salesforce Training Institute in Chennai

salesforce certification online

Fuel Digital Marketing said...

keep posting us.We are the Best Digital Marketing Agency in Chennai, Coimbatore, Madurai and change makers of digital! For Enquiry Contact us @+91 9791811111

digital marketing consultants in chennai | Leading digital marketing agencies in chennai | digital marketing agencies in chennai | Website designers in chennai | social media marketing company in chennai

Training for IT and Software Courses said...

I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.

sap Online Training in bangalore

sap courses in bangalore

sap classes in bangalore

sap Online Training institute in bangalore

sap course syllabus

best sap Online Training

sap Online Training centers

keerthana said...

Thanks a lot for this Article. You don’t know how much you were helped me. I am very new to this kind of tasks. Initially I got fear if I did some thing wrong what will do.
PHP Training in Chennai | Certification | Online Training Course | Machine Learning Training in Chennai | Certification | Online Training Course | iOT Training in Chennai | Certification | Online Training Course | Blockchain Training in Chennai | Certification | Online Training Course | Open Stack Training in Chennai |
Certification | Online Training Course


radhika said...

Really is very interesting, I saw your website and get more details..Nice work.

AWS training in Chennai

AWS Online Training in Chennai

AWS training in Bangalore

AWS training in Hyderabad

AWS training in Coimbatore

AWS training


divya said...

Am really impressed about this blog because this blog is very easy to learn and understand clearly.This blog is very useful for the college students and researchers to take a good notes in good manner,I gained many unknown information.


Data Science Training In Chennai

Data Science Online Training In Chennai

Data Science Training In Bangalore

Data Science Training In Hyderabad

Data Science Training In Coimbatore

Data Science Training

Data Science Online Training

Blogsilly said...

QuickBooks Support Phone Number
QuickBooks Tech Support Number
QuickBooks Technical Support Number
QuickBooks Payroll Support Number

Robert Brown said...
This comment has been removed by the author.
suresh said...

Hey Nice Blog!! Thanks For Sharing!!! Wonderful blog & good post. It is really very helpful to me, waiting for a more new post. Keep Blogging!
DevOps Training in Chennai

DevOps Course in Chennai

SUTAPA said...

সন্তানের মা হলে কি ভালোবাসা বারণ
A letter to my love
অসম্পূর্ণ ভালোবাসা | ছোঁয়া লেগেছিল মাএ
Love story of a single mother
An Affair can’t be Wrong Every Time
একাকীত্ব না ভালোবাসা ?

savas said...

I think this is among the most vital information for me. And i am glad reading your article.
Thanks!
visit my sites Please.

https://www.etsy.com/people/7sq5c42wsanc5jkg?ref=hdr_user_menu-profile
https://gitlab.com/biwisi
https://www.mixcloud.com/pexoya/
https://profile.hatena.ne.jp/pekepi/profile
https://www.bloglovin.com/@lemow

salome said...

thank you .its so useful

Python Training in chennai | Python Classes in Chennai

Aishwariya said...

Awesome post Python Training in Chennai

Jaya said...

Such a great blog.Thanks for sharing...
DevOps Training in Bangalore
Devops Training in Pune
Devops Training in Hyderabad
Devops Training in Gurgaon

Deepak said...

Thanks for this great and useful information. Daynil Group Solutions is one of the leading IT outsourcing companies in India offering Custom Software development ,Web development, Mobile app development, Devops development services all over the world. Reduce your cost by up to 55-65% by outsourcing your software development with us. In Daynil Group we provide end-end services that include product development, testing, and AWS cloud deployment. We use automated CI/CD tooling and an agile development framework. Hire Reactnative developer at low cost and save upto 60% of your Development cost

braven said...

Thank you very much for this article! what is the top training institute for Salesforce in pune

HOME1 said...

Search Coimbatore real estate, Coimbatore property, Coimbatore Home For Sale, Coimbatore Land for Sale, property in Coimbatore, real estate in Coimbatore. Buy Commercial or Industrial Properties in Coimbatore. Buy or Rent residential apartments, flats, house, bungalow, villa in Coimbatore. Search property for sale, rent and PG Coimbatore. Get the best property deals from Coimbatore real estate agents, brokers, dealers and real property owners. Owners List your Coimbatore properties for Rent or Sale for free.
chennai
coimbatore
Home1

kishor said...

thanku so much this information.
free classified submission sites list
visit here

UNIQUE ACADEMY said...

During the current situation of this pandemic, unique is providing the best CS video classes for CSEET and executive level examination, so that there is no chance of downfall in the results of the students
cs executive
freecseetvideolectures/
UNIQUE ACADEMY

Tamil novels said...

Very nice article. Thank you for sharing with us.
Tamil romantic novels
Ramanichandran novels PDF
srikala novels PDF
Mallika manivannan novels PDF
muthulakshmi raghavan novels PDF
Infaa Alocious Novels PDF
N Seethalakshmi Novels PDF
Sashi Murali Tamil Novels

Tamil novels said...
This comment has been removed by the author.
Elena James said...

Trade Stocks, Forex, And Bitcoin Anywhere In The World: roboforex login Is The Leading Provider Of Software That Allows You To Trade On Your Own Terms. Whether You Are Operating In The Forex, Stock, Or Cryptocurrency Markets, Use roboforex login Software And Anonymous Digital Wallet To Connect With The Financial World.: roboforex login Is A Currency Trading Company That Allows You To Trade Stocks, Forex, And Cryptocurrency.

Jobi Johnson said...

Get the latest and good quality clothing items Jackets,Coats and Vests Movies, TV Series, Gaming, Casual,Faux Leather and Leather materials available. john wayne vest

UNIQUE ACADEMY said...

hi thanku somuch this infromation thanku so much
cs executive
freecseetvideolectures/

BK-25 said...

Very Informative blog thank you for sharing. Keep sharing.

Best software training institute in Chennai. Make your career development the best by learning software courses.

blue prism certification in chennai
PHP Training in Chennai
RPA Training in Chennai
DevOps Training in Chennai
Cloud-computing Training in Chennai
Ui-Path Training in Chennai
Azure Training in Chennai

Block said...

Thanks a lot very much for the high quality and results-oriented help.
I won’t think twice to endorse your blog post to anybody who wants
and needs support about this area.
ASP Dot Net Training in Chennai
C Sharp Training in Chennai
big data hadoop training in chennai

Reshma said...

Thanks for sharing such an amazing blog! Kindly update more information
Five Reasons to Use Google Ads
5 Reasons to Use Google Ads

mrbobystone said...

I love to recommend you Where can crawl Exciting Products latest Jackets, Coats and Vests Click Here Alpinestars Biker Jacket

Unknown said...



Nice blog thank you .For your Sharing It's a pleasure to read your post.It's full of information I'm looking for and I'd like to express that "The content of your post is awesome"
manual testing Training in Chennai
Oracle Training in Chennai
Oracle DBA Training in Chennai

Pavithra Devi said...

Great post. Thanks for sharing such a useful blog.
Python Training in T.Nagar
Python training in chennai

George Mark said...

This is the best post I have ever seen. Very clear and simple. Mid-portion Is quite interesting though. Keep doing this. I will visit your site again. Captain America Civil War Steve Rogers Leather Jacket

Matt Reeves said...

This post is so interactive and informative.keep update more information...
Salesforce Training in Tambaram
Salesforce Training in Anna Nagar

milka said...

Great post. keep sharing such a worthy information.
Salesforce Training in Chennai
salesforce training online

Wizular said...

Now, it is possible to view saved wifi passwords on your android device like Mobile, Tablet, ChromeOS etc.
For this purpose, you need to Open the Settings app.
Go to Network & internet (or Connections) and tap Wi-Fi (or Internet on Android 12 and later).
Select the current Wi-Fi network you're connected to, or tap Saved networks to choose a different one.
Tap the Share button.
Authenticate yourself using your PIN, fingerprint, or face recognition.
The password will be displayed below a QR code.
Now, how to decode the QR Code Online, QR Decoder Online will help you to do that very easily by following steps. Regards [ZUCNEE]

«Oldest ‹Older   201 – 271 of 271   Newer› Newest»