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


Java KeyValueTextInputFormat类代码示例

本文整理汇总了Java中org.apache.hadoop.mapred.KeyValueTextInputFormat的典型用法代码示例。如果您正苦于以下问题:Java KeyValueTextInputFormat类的具体用法?Java KeyValueTextInputFormat怎么用?Java KeyValueTextInputFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyValueTextInputFormat类属于org.apache.hadoop.mapred包,在下文中一共展示了KeyValueTextInputFormat类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddInputPathWithMapper

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
public void testAddInputPathWithMapper() {
  final JobConf conf = new JobConf();
  MultipleInputs.addInputPath(conf, new Path("/foo"), TextInputFormat.class,
     MapClass.class);
  MultipleInputs.addInputPath(conf, new Path("/bar"),
     KeyValueTextInputFormat.class, MapClass2.class);
  final Map<Path, InputFormat> inputs = MultipleInputs
     .getInputFormatMap(conf);
  final Map<Path, Class<? extends Mapper>> maps = MultipleInputs
     .getMapperTypeMap(conf);

  assertEquals(TextInputFormat.class, inputs.get(new Path("/foo")).getClass());
  assertEquals(KeyValueTextInputFormat.class, inputs.get(new Path("/bar"))
     .getClass());
  assertEquals(MapClass.class, maps.get(new Path("/foo")));
  assertEquals(MapClass2.class, maps.get(new Path("/bar")));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestMultipleInputs.java

示例2: testAddInputPathWithMapper

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
@Test
public void testAddInputPathWithMapper() {
  final JobConf conf = new JobConf();
  MultipleInputs.addInputPath(conf, new Path("/foo"), TextInputFormat.class,
     MapClass.class);
  MultipleInputs.addInputPath(conf, new Path("/bar"),
     KeyValueTextInputFormat.class, MapClass2.class);
  final Map<Path, InputFormat> inputs = MultipleInputs
     .getInputFormatMap(conf);
  final Map<Path, Class<? extends Mapper>> maps = MultipleInputs
     .getMapperTypeMap(conf);

  assertEquals(TextInputFormat.class, inputs.get(new Path("/foo")).getClass());
  assertEquals(KeyValueTextInputFormat.class, inputs.get(new Path("/bar"))
     .getClass());
  assertEquals(MapClass.class, maps.get(new Path("/foo")));
  assertEquals(MapClass2.class, maps.get(new Path("/bar")));
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:19,代码来源:TestMultipleInputs.java

示例3: run

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
public int run(String[] args) throws Exception {
	Job job = Job.getInstance(getConf(), "map side join");
	Configuration conf = job.getConfiguration();
	job.setJarByClass(getClass());

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

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

	Class<? extends InputFormat> cls = null;
	job.setInputFormatClass(cls);
	// job.setInputFormatClass(CompositeInputFormat.class);
	// 导入路径设置为master和数据两种
	TextInputFormat.addInputPaths(job, args[0]);
	TextInputFormat.addInputPaths(job, args[1]);

	conf.set(CompositeInputFormat.JOIN_EXPR, CompositeInputFormat.compose(
			"inner", KeyValueTextInputFormat.class,
			TextInputFormat.getInputPaths(job)));

	TextOutputFormat.setOutputPath(job, new Path(args[2]));
	job.setOutputFormatClass(TextOutputFormat.class);
	
	return job.waitForCompletion(true)?0:1;
}
 
开发者ID:makelove,项目名称:book-hadoop-hacks,代码行数:28,代码来源:TestMapSide.java

示例4: testAddInputPathWithFormat

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
public void testAddInputPathWithFormat() {
  final JobConf conf = new JobConf();
  MultipleInputs.addInputPath(conf, new Path("/foo"), TextInputFormat.class);
  MultipleInputs.addInputPath(conf, new Path("/bar"),
      KeyValueTextInputFormat.class);
  final Map<Path, InputFormat> inputs = MultipleInputs
     .getInputFormatMap(conf);
  assertEquals(TextInputFormat.class, inputs.get(new Path("/foo")).getClass());
  assertEquals(KeyValueTextInputFormat.class, inputs.get(new Path("/bar"))
     .getClass());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestMultipleInputs.java

示例5: testCreateJob

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
@Test
public void testCreateJob() throws IOException {
  JobConf job;
  ArrayList<String> dummyArgs = new ArrayList<String>();
  dummyArgs.add("-input"); dummyArgs.add("dummy");
  dummyArgs.add("-output"); dummyArgs.add("dummy");
  dummyArgs.add("-mapper"); dummyArgs.add("dummy");
  dummyArgs.add("-reducer"); dummyArgs.add("dummy");
  ArrayList<String> args;
  
  args = new ArrayList<String>(dummyArgs);
  args.add("-inputformat");
  args.add("org.apache.hadoop.mapred.KeyValueTextInputFormat");
  job = StreamJob.createJob(args.toArray(new String[] {}));
  assertEquals(KeyValueTextInputFormat.class, job.getInputFormat().getClass());
  
  args = new ArrayList<String>(dummyArgs);
  args.add("-inputformat");
  args.add("org.apache.hadoop.mapred.SequenceFileInputFormat");
  job = StreamJob.createJob(args.toArray(new String[] {}));
  assertEquals(SequenceFileInputFormat.class, job.getInputFormat().getClass());
  
  args = new ArrayList<String>(dummyArgs);
  args.add("-inputformat");
  args.add("org.apache.hadoop.mapred.KeyValueTextInputFormat");
  args.add("-inputreader");
  args.add("StreamXmlRecordReader,begin=<doc>,end=</doc>");
  job = StreamJob.createJob(args.toArray(new String[] {}));
  assertEquals(StreamInputFormat.class, job.getInputFormat().getClass());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:TestStreamJob.java

示例6: getSplits

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
private InputSplit[] getSplits(JobConf conf, int numSplits, String path) throws Exception
{
  FileInputFormat.setInputPaths(conf, new Path(path));
  if (inputFormat == null) {
    inputFormat = inputFormatClass.newInstance();
    String inputFormatClassName = inputFormatClass.getName();
    if (inputFormatClassName.equals("org.apache.hadoop.mapred.TextInputFormat")) {
      ((TextInputFormat)inputFormat).configure(conf);
    } else if (inputFormatClassName.equals("org.apache.hadoop.mapred.KeyValueTextInputFormat")) {
      ((KeyValueTextInputFormat)inputFormat).configure(conf);
    }
  }
  return inputFormat.getSplits(conf, numSplits);
  // return null;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:MapOperator.java

示例7: testAddInputPathWithFormat

import org.apache.hadoop.mapred.KeyValueTextInputFormat; //导入依赖的package包/类
@Test
public void testAddInputPathWithFormat() {
  final JobConf conf = new JobConf();
  MultipleInputs.addInputPath(conf, new Path("/foo"), TextInputFormat.class);
  MultipleInputs.addInputPath(conf, new Path("/bar"),
      KeyValueTextInputFormat.class);
  final Map<Path, InputFormat> inputs = MultipleInputs
     .getInputFormatMap(conf);
  assertEquals(TextInputFormat.class, inputs.get(new Path("/foo")).getClass());
  assertEquals(KeyValueTextInputFormat.class, inputs.get(new Path("/bar"))
     .getClass());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:13,代码来源:TestMultipleInputs.java


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