Practical exercise unit 7 Topic : MapReduce program in Java Work purpose : Display function, convolution function and the assignment perform the code study


Download 398.17 Kb.
bet1/12
Sana26.03.2023
Hajmi398.17 Kb.
#1296788
  1   2   3   4   5   6   7   8   9   ...   12
Bog'liq
2-deadline


PRACTICAL EXERCISE UNIT - 7


Topic : MapReduce program in Java
Work purpose : Display function , convolution function and the assignment perform the code study _
So So , how do we program MapReduce work we determined . Next step his program code in the form of expression to be need _ To us need : display function , collection function and work perform code _ Mapping function abstract map () method announcement Mapper class that does with is expressed . Map method done upgrade 2.3 is listed shown .
Listing 2.3. Maximum temperature example for display function .

Mapper class parameterized ; his four kind of parameters ¬ mapping of the function access key , access value , output the key and exit of value types determines _ Current in the example input button long whole of the thigh offset is the input value text row , output button year and exit value the air temperature ( integer ). Of the built-in Java types use Hadoop network instead sequencing for optimized local base types present is enough They are org. in the apache.hadoop.io package . Ours our example LongWritable of types uses _ ( analog of Java Long type ), Text ( analog of Java String ) and IntWritable ( to Java Integer similar ).
map() method the key and the value takes _ Enter line own into received text value to a Java type is converted String , from him then the substring() method us interested columns releases _
map ( ) method is also Context sample present is enough exit information to write for ¬. Ours in case year text object as is written . ( because it ¬ only the key as is used ) and temperature IntWritable type placed _ Exit ¬ only temperature value there is if and quality code temperature of information authenticity if it shows is written .
function reduce As shown in Listing 2.4 , the Reducer class similar using _ way is determined .


The work object of the task specification forms and him done increase manage enable gives ¬. Do this on a Hadoop cluster while performing code to a JAR file packaged ( which Hadoop cluster across distributed ). JAR file name sure show instead of the ¬we class of the Job class setJarByClass () method and our migration to Hadoop can _ defined class own into JAR file you received finds _
Job object from creation after information input and release ways shown ( or simpler in other words , input and exit ways ). Enter path is FileInputFormat in the object static addInputPath () method to call through is determined ; he is one file , directory ( this without access given in the directory all from files consists of ) or pattern determine can _ on behalf apparently as the addInputPath ( ) method one how many from the roads access input for repeatedly to be called can _ Exit path ( only one to be can ) FileOutputFormat of the object static setOutputPath () method with is installed . It is a convolution ¬ output of functions files to be written directory determines _ Work from the start before directory there is not to be need , etc without Hadoop warning message emits and work doesn't do it . It is possible has been data of loss prevention get for done is increased ( long continue reached of work the result by chance another data with again to write very nervous ).
Then mapping and shorten types setMapperClass () and se - tReducerClass () methods with is installed .
setOutputKeyClass () and setOutputValueClass () methods of the map exit types control does and most of the time one different has been functions reduces ( our in our case that it was like ). If species from each other difference who does if , exit mapping types ¬ setMapOutputKeyClass () and setMapOutputValueClass () methods with is installed .
Enter types input format point of view in terms of is determined , we do it sure we do not specify because our our example standard TextInput uses ¬Format .
Mapping and folding functions defines classes that you have installed then ¬, work to perform your transition can _ Job class waitForCompletion ( ) method Task perform for submits and his fulfillment waits _ of the method makes sense argument extended exit the flag determines ; our in our case , the task to go about data in the console is displayed .
the waitForCompletion () method Back to value success ( true ) or of failure ( false ) . is a logical ¬ indicator , that is from the program exit converts the code to 0 or 1 .



Download 398.17 Kb.

Do'stlaringiz bilan baham:
  1   2   3   4   5   6   7   8   9   ...   12




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling