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
How to calculate tension.
Evgen [1.6K]

Answer:

Tension can be easily explained in the case of bodies hung from chain, cable, string

Explanation

uniform speed, tension; T = W.

T=m(g±a)

3 0
2 years ago
Let f(t) be an arbitrary signal with bandwidth Ω. Determine the minimum sampling frequencies ωs needed to sample the following a
disa [49]

Answer:

See explaination

Explanation:

We can describr Aliasing as a false frequency which one get when ones sampling rate is less than twice the frequency of your measured signal.

please check attachment for the step by step solution of the given problem.

7 0
3 years ago
Calculate the osmotic pressure of seawater containing 3.5 wt % NaCl at 25 °C . If reverse osmosis is applied to treat seawater,
AlladinOne [14]

Answer:

Highest osmotic pressure that membrane may experience is

' =58.638 atm

Explanation:

Suppose sea-water taken is M= 1 kg

Density of water = 1000 kg/m3

Therefore Volume of water= Mass,M/Density of water

V= 1 kg/(1000 kg/m3)

V= 10-3 m3= 1 Litre

Since mass of Nacl is 3.5 wt%,Therefore in 1 kg of water

Mass present of NaCl= m= 0.035*1000 g

m= 35 g

Since molecular weight of NaCl= 58.44 g/mol =M.W.

Thus its Number of moles of Nacl= m/M.W

nNaCl= 35g/58.44 gmol-1

= 0.5989 mol

ans since volume of solution is 1 L thus concentration of NaCl is ,C= number of moles/Volume of solution in Litres

C= 0.5989mol/ 1L

=0.5989 M

Since 1 mol NaCL disssociates to form 2 moles of ions of Na+ andCl- Thus van't hoff factor i=2

And osmotic pressure  = iCRT ------------------------------(1)( Where R= 0.0821 L.atm/mol.K and T= 25oC= 298.15 K)

Putting in equation 1 ,we get  = 2*(0.5989 mol/L)*(0.0821 L.atm/mol.K)*298.15 K

=29.319 atm

Now as the water gets filtered out of the membrane,the water's volume decreases and concentration C of NacL increases, thus osmotic pressure also increases.Thus, at 50% water been already filtered out, the osmotic pressure at the membrane will be maximum

Thus Volume of water left after 50% is filtered out as fresh water= 0.5 L (assuming no salt passes through semi permeable membrane)

Thus New concentration of NaCl C'= 2*C

C'=2*0.5989 M

=1.1978 M

and Since Osmotic pressure is directly proportional to concentration, Thus As concentration C doubles to C', Osmotic Pressure  ' also doubles from  ,

Thus,Highest osmotic pressure that membrane may experience is,  '=2*  

=2*29.319 atm

' =58.638 atm

3 0
3 years ago
For laminar flow over a hot flat plate, the local heat transfer coefficient decreases with distance because (select all that are
kotegsom [21]

Answer:

B. The thickness of the heated region near the plate is increasing.

Explanation:

First we know that, a boundary layer is the layer of fluid in the immediate vicinity of a bounding surface where the effects of viscosity are significant. The fluid is often slower due to the effects of viscosity. Advection i.e the transfer of heat by the flow of liquid becomes less since the flow is slower, thereby the local heat transfer coefficient decreases.

From law of conduction, we observe that heat transfer rate will decrease based on a smaller rate of temperature, the thickness therefore increases while the local heat transfer coefficient decreases with distance.

3 0
3 years ago
If the price of the car is less than or equal to your available cash, display "no". If the price of the car is more than your av
Ede4ka [16]

Answer:

function decision(car_price, available_cash) {

   if(car_price <= available_cash) {

   console.log("no");

   }

   else  {

   console.log("yes");

   }

   }

decision(car_price, available_cash); or decision(available_cash, car_price);

Explanation:

using functions in Javascript:

functions; this refers to dividing codes into reusable parts.

e.g function function_name() {

console.log("How are you?");

}

you can call or invoke this function by using its name followed by parenthesis, like this: function_name(). each time the function is called it will   print out "How are you?".

Parameters: these are variables that act as placeholders for the values that are to be input into a function when it is called

Arguments: The actual values that input or passed into a function when it is called.

e.g

function function_name(parameter1, parameter2) {

console.log(parameter1, parameter2);

}

then we call function_name: function_name("please", "leave"):we have passed two arguments, "please"  and "leave". Inside the function parameter1 equals "please" while parameter2 equals "leave".

Hence, from the question given the two parameters "car_price" and "available_cash" respectively, we write the function with name function_name:

function decision(car_price, available_cash) {

   if(car_price <= available_cash) {

   console.log("no");

   }

   else  {

   console.log("yes");

   }

   }

decision(car_price, available_cash); or decision(available_cash, car_price);

7 0
3 years ago
Other questions:
  • A common way of measuring the thermal conductivity of a material is to sandwich an electric thermofoil heater between two identi
    9·1 answer
  • 1- A square-wave inverter has a dc source of 96 V and an output frequency of 60 Hz. The load is a series RL load with R = 5 Ohm
    7·1 answer
  • The bulk modulus of a material is 3.5 ✕ 1011 N/m2. What percent fractional change in volume does a piece of this material underg
    13·1 answer
  • 5. What are the 3 basic types of electrical circuits?
    12·1 answer
  • Question 54 (1 point)
    11·2 answers
  • How will the proposed study contribute to your career?*<br>(quantity Surveying​
    11·1 answer
  • Which of these parts of a cell phone is least likely to be found on the phone's circult board?
    5·1 answer
  • How much memory can a 32 -bit processor support ?
    13·1 answer
  • Who works alongside and assists the engineers?
    5·1 answer
  • Task Three :Write a C++ program to read temperature
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!