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


Java FakeSplit类代码示例

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


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

示例1: testFormat

import org.apache.hadoop.mapred.pipes.TestPipeApplication.FakeSplit; //导入依赖的package包/类
/**
 *  test PipesNonJavaInputFormat
  */

@Test
public void testFormat() throws IOException {

  PipesNonJavaInputFormat inputFormat = new PipesNonJavaInputFormat();
  JobConf conf = new JobConf();

  Reporter reporter= mock(Reporter.class);
  RecordReader<FloatWritable, NullWritable> reader = inputFormat
      .getRecordReader(new FakeSplit(), conf, reporter);
  assertEquals(0.0f, reader.getProgress(), 0.001);

  // input and output files
  File input1 = new File(workSpace + File.separator + "input1");
  if (!input1.getParentFile().exists()) {
    Assert.assertTrue(input1.getParentFile().mkdirs());
  }

  if (!input1.exists()) {
    Assert.assertTrue(input1.createNewFile());
  }

  File input2 = new File(workSpace + File.separator + "input2");
  if (!input2.exists()) {
    Assert.assertTrue(input2.createNewFile());
  }
  // set data for splits
  conf.set(org.apache.hadoop.mapreduce.lib.input.FileInputFormat.INPUT_DIR,
      StringUtils.escapeString(input1.getAbsolutePath()) + ","
          + StringUtils.escapeString(input2.getAbsolutePath()));
  InputSplit[] splits = inputFormat.getSplits(conf, 2);
  assertEquals(2, splits.length);

  PipesNonJavaInputFormat.PipesDummyRecordReader dummyRecordReader = new PipesNonJavaInputFormat.PipesDummyRecordReader(
      conf, splits[0]);
  // empty dummyRecordReader
  assertNull(dummyRecordReader.createKey());
  assertNull(dummyRecordReader.createValue());
  assertEquals(0, dummyRecordReader.getPos());
  assertEquals(0.0, dummyRecordReader.getProgress(), 0.001);
   // test method next
  assertTrue(dummyRecordReader.next(new FloatWritable(2.0f), NullWritable.get()));
  assertEquals(2.0, dummyRecordReader.getProgress(), 0.001);
  dummyRecordReader.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:TestPipesNonJavaInputFormat.java

示例2: testFormat

import org.apache.hadoop.mapred.pipes.TestPipeApplication.FakeSplit; //导入依赖的package包/类
/**
 *  test PipesNonJavaInputFormat
  */

@Test
public void testFormat() throws IOException {

  PipesNonJavaInputFormat inputFormat = new PipesNonJavaInputFormat();
  JobConf conf = new JobConf();

  Reporter reporter= mock(Reporter.class);
  RecordReader<FloatWritable, NullWritable> reader = inputFormat
      .getRecordReader(new FakeSplit(), conf, reporter);
  assertEquals(0.0f, reader.getProgress(), 0.001);

  // input and output files
  File input1 = new File(workSpace + File.separator + "input1");
  if (!input1.getParentFile().exists()) {
    Assert.assertTrue(input1.getParentFile().mkdirs());
  }

  if (!input1.exists()) {
    Assert.assertTrue(input1.createNewFile());
  }

  File input2 = new File(workSpace + File.separator + "input2");
  if (!input2.exists()) {
    Assert.assertTrue(input2.createNewFile());
  }
  // set data for splits
  conf.set(org.apache.hadoop.mapreduce.lib.input.FileInputFormat.INPUT_DIR,
      input1.getAbsolutePath() + "," + input2.getAbsolutePath());
  InputSplit[] splits = inputFormat.getSplits(conf, 2);
  assertEquals(2, splits.length);

  PipesNonJavaInputFormat.PipesDummyRecordReader dummyRecordReader = new PipesNonJavaInputFormat.PipesDummyRecordReader(
      conf, splits[0]);
  // empty dummyRecordReader
  assertNull(dummyRecordReader.createKey());
  assertNull(dummyRecordReader.createValue());
  assertEquals(0, dummyRecordReader.getPos());
  assertEquals(0.0, dummyRecordReader.getProgress(), 0.001);
   // test method next
  assertTrue(dummyRecordReader.next(new FloatWritable(2.0f), NullWritable.get()));
  assertEquals(2.0, dummyRecordReader.getProgress(), 0.001);
  dummyRecordReader.close();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:48,代码来源:TestPipesNonJavaInputFormat.java


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