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]
2 years ago
13

JAVA HADOOP MAPREDUCE

Engineering
1 answer:
taurus [48]2 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
Define an ADT for a two-dimensional array of integers. Specify precisely the basic operations that can be performed on such arra
VashaNatasha [74]

Answer:

Explanation:

ADT for an 2-D array:

struct array{

int arr[10];

}arrmain[10];

An application that stores an array with 1000 rows and 1000 columns, where less than 10,000 of the array values are non-zero. The two different implementations for such arrays that would be more space efficient than a standard two-dimensional array implementation requiring one million positions are :

1) struct array{

int *p;

}arr[1000];

2) struct array{

int *p;

}arr[1000];

6 0
3 years ago
Fast plz-The mirror check may involve ______________.
barxatty [35]

Answer:

Realigning the mirror

Explanation:

mirrors should be aligned to minimize blind spots, not look at the tires.

6 0
2 years ago
When a person has the ability to move a vehicle, they have ____________________.
sergiy2304 [10]

(Energy ) i think .....

4 0
3 years ago
Training is a way for employers to provide ____ to enable employees to protect themselves and others from injuries.
Andreyy89

Answer:

Training is a way for employers to provide tools to enable employees to protect themselves and others from injuries.

Explanation:

5 0
2 years ago
Read 2 more answers
What statement exemplifies the role of archeology in architecture?
horrorfan [7]
The answer is B because an architect designs buildings
5 0
2 years ago
Other questions:
  • Let suppose, you are going to develop a web-application for school management system. Then what architectural pattern will you u
    9·1 answer
  • Air as an ideal gas in a closed system undergoes a reversible process between temperatures of 1000 K and 400 K. The beginning pr
    9·1 answer
  • When fermentation units are operated with high aeration rates, significant amounts of water can be evaporated into the air passi
    13·1 answer
  • Write a complete C++ program that is made of functions main() and rShift(). The rShift() function must be a function without ret
    7·1 answer
  • The rate of energy transfer by work is called power. a)-True b)-False
    15·1 answer
  • Are spheroidized steels considered as composite? If so, what is the dispersed phase a)- No b)- Yes, Chromium Carbides c)- Yes, I
    12·1 answer
  • Air enters the combustor of a jet engine at p1=10 atm, T1=1000°R, and M1=0.2. Fuel is injected and burned, with a fuel/air mass
    7·1 answer
  • Oxygen combines with nitrogen in the air to form NOx at about
    6·2 answers
  • Uber drivers are considered 'independent contractors' and thus can apply for business licenses.
    11·2 answers
  • In order to avoid a rollover, what is the highest degree incline one should mow on? 10-degree incline 5-degree incline 30-degree
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!