Skip to content

Commit

Permalink
Update more ch07 examples to use new API.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Sep 28, 2011
1 parent 1f4b02c commit 877a834
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
10 changes: 4 additions & 6 deletions ch07/src/main/java/MinimalMapReduceWithDefaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,22 @@ public int run(String[] args) throws Exception {
return -1;
}

/*[*/job.setInputFormatClass(TextInputFormat.class); // cf setInputFormat
/*[*/job.setInputFormatClass(TextInputFormat.class);

// job.setNumMapTasks(1); cf not in new API
job.setMapperClass(Mapper.class); // Mapper is abstract and the identity
//job.setMapRunnerClass(MapRunner.class); // Override Mapper to control flow
job.setMapperClass(Mapper.class);

job.setMapOutputKeyClass(LongWritable.class);
job.setMapOutputValueClass(Text.class);

job.setPartitionerClass(HashPartitioner.class);

job.setNumReduceTasks(1);
job.setReducerClass(Reducer.class); // identity
job.setReducerClass(Reducer.class);

job.setOutputKeyClass(LongWritable.class);
job.setOutputValueClass(Text.class);

job.setOutputFormatClass(TextOutputFormat.class);/*]*/ // cf setOutputFormat
job.setOutputFormatClass(TextOutputFormat.class);/*]*/

return job.waitForCompletion(true) ? 0 : 1;
}
Expand Down
3 changes: 2 additions & 1 deletion ch07/src/main/java/NonSplittableTextInputFormat.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// == NonSplittableTextInputFormat
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;

public class NonSplittableTextInputFormat extends TextInputFormat {
@Override
protected boolean isSplitable(JobContext context, Path file) {;
protected boolean isSplitable(JobContext context, Path file) {
return false;
}
}
2 changes: 2 additions & 0 deletions snippet/bin/check_manuscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Check that the expected (or actual) snippets are in the manuscript. E.g.
# bin/check_manuscript.py ~/workspace/htdg2/ch11.xml expected/ch11/grunt/*

# TODO: ignore id elements in the XML in the book.
# Need to use an XML parser for this.
import sys

manuscript = open(sys.argv[1], 'r').read()
Expand Down
4 changes: 3 additions & 1 deletion snippet/bin/check_manuscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ actual="$bin"/../actual

$bin/check_manuscript.py ~/workspace/htdg3/ch02.xml $actual/ch02/*
$bin/check_manuscript.py ~/workspace/htdg3/ch04.xml $actual/ch04/*
$bin/check_manuscript.py ~/workspace/htdg3/ch05.xml $actual/ch05/*
$bin/check_manuscript.py ~/workspace/htdg3/ch05.xml $actual/ch05/*
$bin/check_manuscript.py ~/workspace/htdg3/ch07.xml $actual/ch07/*
$bin/check_manuscript.py ~/workspace/htdg3/ch07.xml $actual/common/*
2 changes: 2 additions & 0 deletions snippet/bin/generate_listings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ actual="$bin"/../actual
perl $bin/phragmite_db.pl $actual/ch02/ $(grep -ElR '(// ?cc|// ?==)' --include '*.java' $bin/../../ch02)
perl $bin/phragmite_db.pl $actual/ch04/ $(grep -ElR '(// ?cc|// ?==)' --include '*.java' $bin/../../ch04)
perl $bin/phragmite_db.pl $actual/ch05/ $(grep -ElR '(// ?cc|// ?==)' --include '*.java' $bin/../../ch05)
perl $bin/phragmite_db.pl $actual/ch07/ $(grep -ElR '(// ?cc|// ?==)' --include '*.java' $bin/../../ch07)
perl $bin/phragmite_db.pl $actual/common/ $(grep -ElR '(// ?cc|// ?==)' --include '*.java' $bin/../../common)

0 comments on commit 877a834

Please sign in to comment.