1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natka813 [3]
3 years ago
13

JAVA HADOOP MAPREDUCE

Engineering
1 answer:
taurus [48]3 years ago
3 0

Answer:

Explanation:

package PackageDemo;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.LongWritable;

import org.apache.hadoop.io.Text;

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 {

public static void main(String [] args) throws Exception

{

Configuration c=new Configuration();

String[] files=new GenericOptionsParser(c,args).getRemainingArgs();

Path input=new Path(files[0]);

Path output=new Path(files[1]);

Job j=new Job(c,"wordcount");

j.setJarByClass(WordCount.class);

j.setMapperClass(MapForWordCount.class);

j.setReducerClass(ReduceForWordCount.class);

j.setOutputKeyClass(Text.class);

j.setOutputValueClass(IntWritable.class);

FileInputFormat.addInputPath(j, input);

FileOutputFormat.setOutputPath(j, output);

System.exit(j.waitForCompletion(true)?0:1);

}

public static class MapForWordCount extends Mapper<LongWritable, Text, Text, IntWritable>{

public void map(LongWritable key, Text value, Context con) throws IOException, InterruptedException

{

String line = value.toString();

String[] words=line.split(",");

for(String word: words )

{

Text outputKey = new Text(word.toUpperCase().trim());

IntWritable outputValue = new IntWritable(1);

con.write(outputKey, outputValue);

}

}

}

public static class ReduceForWordCount extends Reducer<Text, IntWritable, Text, IntWritable>

{

public void reduce(Text word, Iterable<IntWritable> values, Context con) throws IOException, InterruptedException

{

int sum = 0;

for(IntWritable value : values)

{

sum += value.get();

}

con.write(word, new IntWritable(sum));

}

}

}

You might be interested in
A room is kept at −5°C by a vapor-compression refrigeration cycle with R-134a as the refrigerant. Heat is rejected to cooling wa
Fed [463]

Answer:

note:

<u>solution is attached in word form due to error in mathematical equation. furthermore i also attach Screenshot of solution in word due to different version of MS Office please find the attachment</u>

Download docx
4 0
3 years ago
Read 2 more answers
Explain why the following scenario fails to meet the criteria for proper reverse engineering.
avanturin [10]

Answer:

he must document or remember the order he took it apart so he put it back together

Explanation:

5 0
2 years ago
What type of foundation do engineers use for a small and light building and when the load of the building is borne by columns? A
ikadub [295]

Answer:

A.

Explanation:

Individual footings are the commonest, and they are often used if the load of the building is borne by columns. Typically, every column will have an own footing. The footing is usually only a rectangular or square pad of concrete on which the column is erected

8 0
3 years ago
How does the "E" in STEM work with the other letters
KIM [24]

Answer:

if you are speaking of the acronym then Engineering uses science and mathematics to solve everyday problems in society

4 0
3 years ago
3.94 x 105) + (2.04 x 105)
Flura [38]
627.9 is the answer
6 0
3 years ago
Other questions:
  • A reversible refrigerator operates between a low temperature reservoir at TL and a high temperature reservoir at TH . Its coeffi
    12·1 answer
  • Consider a steam turbine, with inflow at 500oC and 7.9 MPa. The machine has a total-to-static efficiency ofηts=0.91, and the pre
    14·1 answer
  • Consider the following program:
    15·1 answer
  • Assess the capabilities of a hydroelectric power plant from the following field data: Estimated water flow rate, 40 m3/s River i
    9·1 answer
  • You are analyzing an open-return wind tunnel that intakes air at 20 m/s and 320K. When the flow exits the wind tunnel it is movi
    14·2 answers
  • Simplify the following expressions, then implement them using digital logic gates. (a) f = A + AB + AC (b) f = AB + AC + BC (c)
    5·1 answer
  • Consider a 400 mm × 400 mm window in an aircraft. For a temperature difference of 90°C from the inner to the outer surface of th
    10·1 answer
  • What is the friction factor for fully developed flow in a circular pipe where Reynolds number is 1000
    6·1 answer
  • What is the difference between POP3 and IMAP?
    5·1 answer
  • True or false for the 4 questions?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!