当前位置: 首页>>代码示例>>Java>>正文


Java TokenCounterMapper类代码示例

本文整理汇总了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));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestSingleElementChain.java

示例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));
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:24,代码来源:TestSingleElementChain.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:Data-Science-with-Hadoop,代码行数:14,代码来源:WordCountPredefined.java

示例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);
}
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:28,代码来源:Main.java

示例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);
}
 
开发者ID:project-asap,项目名称:IReS-Platform,代码行数:11,代码来源:WordCountJob.java

示例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;
		
}
 
开发者ID:aadishgoel2013,项目名称:Hadoop-Codes,代码行数:19,代码来源:countingDriver.java


注:本文中的org.apache.hadoop.mapreduce.lib.map.TokenCounterMapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。