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
Plz solve the problem
julsineya [31]
I attached a photo that explains and gives the answer to your questions. Had to add a border because the whole picture didn’t fit.

6 0
3 years ago
Paint can shaker mechanisms are common in paint and hardware stores. While they do a good job of mixing the paint, they are also
Ymorist [56]

Answer:

A good design for a portable device to mix paint minimizing the shaking forces and vibrations while still effectively mixing the paint. Is:

The best design is one with centripetal movement. Instead of vertical or horizontal movement. With a container and system of holding structures made of materials that could absorb the vibration effectively.

Explanation:

First of all centripetal movement would be friendlier to our objective as it would not shake the can or the machine itself with disruptive vibrations. Also, we would have to use materials with a good grade of force absorption to eradicate the transmission of the movement to the rest of the structure. Allowing the reduction of the shaking forces while maintaining it effective in the process of mixing.

6 0
3 years ago
An Ideal gas is being heated in a circular duct as while flowing over an electric heater of 130 kW. The diameter of duct is 500
max2010maxim [7]

Answer: The exit temperature of the gas in deg C is 32^{o}C.

Explanation:

The given data is as follows.

C_{p} = 1000 J/kg K,   R = 500 J/kg K = 0.5 kJ/kg K (as 1 kJ = 1000 J)

P_{1} = 100 kPa,     V_{1} = 15 m^{3}/s

T_{1} = 27^{o}C = (27 + 273) K = 300 K

We know that for an ideal gas the mass flow rate will be calculated as follows.

     P_{1}V_{1} = mRT_{1}

or,         m = \frac{P_{1}V_{1}}{RT_{1}}

                = \frac{100 \times 15}{0.5 \times 300}

                = 10 kg/s

Now, according to the steady flow energy equation:

mh_{1} + Q = mh_{2} + W

h_{1} + \frac{Q}{m} = h_{2} + \frac{W}{m}

C_{p}T_{1} - \frac{80}{10} = C_{p}T_{2} - \frac{130}{10}

(T_{2} - T_{1})C_{p} = \frac{130 - 80}{10}

(T_{2} - T_{1}) = 5 K

T_{2} = 5 K + 300 K

T_{2} = 305 K

           = (305 K - 273 K)

           = 32^{o}C

Therefore, we can conclude that the exit temperature of the gas in deg C is 32^{o}C.

7 0
3 years ago
Question 7.1: Two possible overhead valve combustion chambers are being considered – the first has two valves; the second has fo
AleksandrR [38]

Answer:

1) The adoption of the second design we can see that the total valve perimeter is increased by 60.8%

2) Increase in flow are : 29%

3) Additional benefits in using 4 valves per cylinder:

a)For the purpose of controlling the combustion process, the inlet valves will give more flexibility

b) There is a larger valve throat areas for the flow of gas

Explanation:

1) Perimeter of the first possible overhead valve combustion chamber with two valves:

P₂ = πd = π × 23 = 72.26mm

Perimeter of the second possible overhead valve combustion chamber with four valves:

P₄ = π2d = π × 18.5 × 2 = 116.24 mm

If second design is adopted, percentage increase = ((P₄ - P₂)/P₂)×100

     = ((116.24 - 72.26)/72.26)×100 = 0.6086 ×100 = 60.86%

Therefore, the total valve perimeter is shown to have increased by 60.8%

2) Formula for flow Area (A) = P × L = πkd²

Area of the first possible overhead valve combustion chamber with two valves: A₂ = πkd² = πk(23)² = 1662k mm²

Area of the first possible overhead valve combustion chamber with four valves: A₄ = πkd² = 2πk(18.5)² = 2150k mm²

The percentage increase in flow area: ((A₄ - A₂)/A₄)×100 = ((2150 - 1662)/2150)×100 = 29%

3) The additional benefits of using are:

a) For the purpose of controlling the combustion process, the inlet valves will give more flexibility

b) There is a larger valve throat areas for the flow of gas

           

7 0
3 years ago
Which of the following hazards is shared by surface mining and sub-surface mining?
lubasha [3.4K]

B I guess. since they both have potential to collapse

4 0
3 years ago
Read 2 more answers
Other questions:
  • The assembly consists of two red brass C83400 copper alloy rods AB and CD of diameter 30 mm, a stainless 304 steel alloy rod EF
    11·1 answer
  • A well-insulated tank in a vapor power plant operates at steady state. Saturated liquid water enters at inlet 1 at a rate of 125
    6·2 answers
  • You have a solid square copper ground support, 2 inch per side X 6 inches tall, and it is loaded axially (long axis)with 1600 po
    11·1 answer
  • Please describe a real situation in which you had to troubleshoot and fix the failure of a piece equipment/machine?
    5·1 answer
  • Joe Bruin has a big lawn in front of his house that is 30 meters wide and 20 meters long. Josephine makes him go out and mow the
    5·1 answer
  • Basic output with variables (Java) This zyLab activity is intended for students to prepare for a larger programming assignment.
    7·1 answer
  • What are 5 advantages of wood as a manufacturing or construction​
    12·1 answer
  • A fan draws air from the atmosphere through a 0.30-mdiameter round duct that has a smoothly rounded entrance. A differential man
    14·1 answer
  • A series of concrete pillars have been built on the border between Kuwait and Iraq. They are there to __________ the border.
    8·1 answer
  • a low velocity fastening system that is used to drive steel pins or threaded studs into a masonry and steel is a
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!