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
Do all websites use the same coding to create?
Sonbull [250]

Answer:

yes.

Explanation:

because all websites use coding

6 0
3 years ago
21. How long can food that requires time-temperature control be left in the danger zone?
dimulka [17.4K]

Answer: A maximum of 1 hour

Explanation:

Read your lesson buddy!!

8 0
3 years ago
Read 2 more answers
An AX ceramic compound has the rock salt crystal structure. If the radii of the A and X ions are 0.137 and 0.241 nm, respectivel
Tju [1.3M]

Answer:

c) 1.75 g/cm³

Explanation:

Given that

Radii of the A ion, r(c) = 0.137 nm

Radii of the X ion, r(a) = 0.241 nm

Atomic weight of the A ion, A(c) = 22.7 g/mol

Atomic weight of the X ion, A(a) = 91.4 g/mol

Avogadro's number, N = 6.02*10^23 per mol

Solution is attached below

3 0
3 years ago
Where are the ar manufacturers not fitting the engine in the high end sport cars
fomenos

Answer:

it depends on the but i would recommend check in the front next to the turbo intake.

8 0
2 years ago
Can you help me with this
Fiesta28 [93]

the function is to provide sealed combustion so that the loss of gas is minimized

6 0
2 years ago
Other questions:
  • Please help me fast, I don’t have time
    15·1 answer
  • The pressure in an automobile tire depends on thetemperature of the air in the tire. When the air temperature is25°C, the pressu
    11·1 answer
  • In digital communication technologies, what is an internal network also known as?
    9·1 answer
  • Sadadasdasdasdasdadaaasd1
    14·1 answer
  • PLZZZZZ HELP
    7·2 answers
  • Is the pure fission bomb a nuclear bomb?
    5·1 answer
  • For binary flash distillation, we discussed in class that there are 8 variables (F, ZA, V, ya, L, XA, P and T) and 4 equations d
    10·1 answer
  • Explain the problems and their possible solution for electricity problems ?​
    8·1 answer
  • A tank with a volume of 40 cuft is filled with a carbon dioxide and air mixture. The pressure within the tank is 30 psia at 70oF
    12·1 answer
  • A system of organization, people activities, informations, and resources involved in supplying a productor or service to a custo
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!