本文整理汇总了Java中org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper类的典型用法代码示例。如果您正苦于以下问题:Java TokenCounterMapper类的具体用法?Java TokenCounterMapper怎么用?Java TokenCounterMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TokenCounterMapper类属于org.apache.hadoop.mapreduce.lib.map包,在下文中一共展示了TokenCounterMapper类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNoChain
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper; //导入依赖的package包/类
public void testNoChain() throws Exception {
Path inDir = new Path(localPathRoot, "testing/chain/input");
Path outDir = new Path(localPathRoot, "testing/chain/output");
String input = "a\nb\na\n";
String expectedOutput = "a\t2\nb\t1\n";
Configuration conf = createJobConf();
Job job = MapReduceTestUtil.createJob(conf, inDir, outDir, 1, 1, input);
job.setJobName("chain");
ChainMapper.addMapper(job, TokenCounterMapper.class, Object.class,
Text.class, Text.class, IntWritable.class, null);
ChainReducer.setReducer(job, IntSumReducer.class, Text.class,
IntWritable.class, Text.class, IntWritable.class, null);
job.waitForCompletion(true);
assertTrue("Job failed", job.isSuccessful());
assertEquals("Outputs doesn't match", expectedOutput, MapReduceTestUtil
.readOutput(outDir, conf));
}
示例2: testNoChain
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper; //导入依赖的package包/类
@Test
public void testNoChain() throws Exception {
Path inDir = new Path(localPathRoot, "testing/chain/input");
Path outDir = new Path(localPathRoot, "testing/chain/output");
String input = "a\nb\na\n";
String expectedOutput = "a\t2\nb\t1\n";
Configuration conf = createJobConf();
Job job = MapReduceTestUtil.createJob(conf, inDir, outDir, 1, 1, input);
job.setJobName("chain");
ChainMapper.addMapper(job, TokenCounterMapper.class, Object.class,
Text.class, Text.class, IntWritable.class, null);
ChainReducer.setReducer(job, IntSumReducer.class, Text.class,
IntWritable.class, Text.class, IntWritable.class, null);
job.waitForCompletion(true);
assertTrue("Job failed", job.isSuccessful());
assertEquals("Outputs doesn't match", expectedOutput, MapReduceTestUtil
.readOutput(outDir, conf));
}
示例3: main
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
Configuration conf = new Configuration();
Job job = new Job(conf, "word count1");
job.setJarByClass(WordCountPredefined.class);
job.setMapperClass(TokenCounterMapper.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
示例4: main
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
String input=null, output =null;
if (args.length!=2){
System.err.println("This Job takes exactly 2 arguments: input, output");
System.exit(-1);
}
else{
input=args[0];
output=args[1];
}
Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "word count");
job.setJarByClass(Main.class);
job.setMapperClass(TokenCounterMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(input));
Path output_path = new Path(output);
(FileSystem.get(conf)).delete(output_path, true); //remove previous output
FileOutputFormat.setOutputPath(job,output_path );
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
示例5: JobConfig
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper; //导入依赖的package包/类
@Override
public void JobConfig() {
job.setJarByClass(Main.class);
job.setMapperClass(TokenCounterMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
}
示例6: main
import org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
Configuration conf= new Configuration();
Job job = Job.getInstance(conf, "countword");
job.setMapperClass(TokenCounterMapper.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
if(!job.waitForCompletion(false))
return;
}