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
Two loads connected in parallel draw a total of 2.4 kW at 0.8 pf lagging from a 120-V rms, 60-Hz line. One load absorbs 1.5 kW a
stealth61 [152]

Answer: a) 0.948 b) 117.5µf

Explanation:

Given the load, a total of 2.4kw and 0.8pf

V= 120V, 60 Hz

P= 2.4 kw, cos θ= 80

P= S sin θ - (p/cos θ) sin θ

= P tan θ(cos^-1 (0.8)

=2.4 tan(36.87)= 1.8KVAR

S= 2.4 + j1. 8KVA

1 load absorbs 1.5 kW at 0.707 pf lagging

P= 1.5 kW, cos θ= 0.707 and θ=45 degree

Q= Ptan θ= tan 45°

Q=P=1.5kw

S1= 1.5 +1.5j KVA

S1 + S2= S

2.4+j1.8= 1.5+1.5j + S2

S2= 0.9 + 0.3j KVA

S2= 0.949= 18.43 °

Pf= cos(18.43°) = 0.948

b.) pf to 0.9, a capacitor is needed.

Pf = 0.9

Cos θ= 0.9

θ= 25.84 °

(WC) V^2= P (tan θ1 - tan θ2)

C= 2400 ( tan (36. 87°) - tan (25.84°)) /2 πf × 120^2

f=60, π=22/7

C= 117.5µf

7 0
3 years ago
Please help will give brainliest please answer all 3
larisa [96]

Answer: For #1 I'm going to go with A because that has to do with biology

For #2 I'm going to go with B oceans because that has to do with plant life (and life in general).

For #3 I'll say marine/maritime engineer (you can just say marine)

Hope it helps!

8 0
4 years ago
These tadpoles are confined to a limited environment. What are they all competing for in that environment
Dovator [93]

Answer: to the earth air

Explanation:

5 0
3 years ago
Read 2 more answers
A rigid tank contains an ideal gas at 40°C that is being stirred by a paddle wheel. The paddle wheel does 240 kJ of work on the
Sergeu [11.5K]

To solve the problem it is necessary to consider the concepts and formulas related to the change of ideal gas entropy.

By definition the entropy change would be defined as

\Delta S = C_p ln(\frac{T_2}{T_1})-Rln(\frac{P_2}{P_1})

Using the Boyle equation we have

\Delta S = C_p ln(\frac{T_2}{T_1})-Rln(\frac{v_1T_2}{v_2T_1})

Where,

C_p = Specific heat at constant pressure

T_1= Initial temperature of gas

T_2= Final temprature of gas

R = Universal gas constant

v_1= Initial specific Volume of gas

v_2= Final specific volume of gas

According to the statement, it is an isothermal process and the tank is therefore rigid

T_1 = T_2, v_2=v_1

The equation would turn out as

\Delta S = C_p ln1-ln1

<em>Therefore the entropy change of the ideal gas is 0</em>

Into the surroundings we have that

\Delta S = \frac{Q}{T}

Where,

Q = Heat Exchange

T = Temperature in the surrounding

Replacing with our values we have that

\Delta S = \frac{230kJ}{(30+273)K}

\Delta S = 0.76 kJ/K

<em>Therefore the increase of entropy into the surroundings is 0.76kJ/K</em>

8 0
3 years ago
EggzOG43199 <br><br><br><br> :) it has to be more than 20 characters so I'm just saying this
lawyer [7]

Answer:

giberishgiberishgiberishgiberishgiberishgiberishgiberishgiberishgiberish

Explanation:

i have no idea what the question is but do u 4 real need help?

8 0
3 years ago
Other questions:
  • Explain the purpose of the checkpoint mechanism. How often should checkpoints be performed?How does the frequency of checkpoints
    6·1 answer
  • A cast-iron tube is used to support a compressive load. Knowing that E 5 10 3 106 psi and that the maximum allowable change in l
    11·1 answer
  • A 350 m^3 retention pond that holds rainwater from a shopping mall is empty at the beginning of a rainstorm. The flow rate out o
    7·1 answer
  • Acredit report summarizes a person's Acredit score is measure of a person's as a borrower a factor that contributes to a person'
    15·1 answer
  • In the ______ phase of the organizational life cycle, the organization is usually very small and agile, focusing on new products
    8·1 answer
  • 6.3.3 Marks on an exam in a statistics course are assumed to be normally distributed
    14·1 answer
  • A motor cycle is moving up an incline of 1 in 30 at a speed of 80 km/h,and then suddenly the engine shuts down.The tractive resi
    11·1 answer
  • A 2.0-in-thick slab is 10.0 in wide and 12.0 ft long. Thickness is to be reduced in three steps in a hot rolling operation. Each
    9·1 answer
  • There are some sections of the SDS that are not mandatory.
    11·1 answer
  • What happens if you leave your car on while pumping gas
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!