Package org.apache.hadoop.mrunit.types

Examples of org.apache.hadoop.mrunit.types.TestWritable$Comparator


    // this test should use the comparator registered inside TestWritable
    // to output the keys in reverse order
    MapReduceDriver<TestWritable,Text,TestWritable,Text,TestWritable,Text> driver
      = MapReduceDriver.newMapReduceDriver(new Mapper(), new Reducer());
   
    driver.withInput(new TestWritable("A1"), new Text("A1"))
      .withInput(new TestWritable("A2"), new Text("A2"))
      .withInput(new TestWritable("A3"), new Text("A3"))
      .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
      // TODO: these output keys are incorrect because of MRUNIT-129
      .withOutput(new TestWritable("A3"), new Text("A3"))
      .withOutput(new TestWritable("A3"), new Text("A2"))
      .withOutput(new TestWritable("A3"), new Text("A1"))
      //the following are the actual correct outputs
      //.withOutput(new TestWritable("A3"), new Text("A3"))
      //.withOutput(new TestWritable("A2"), new Text("A2"))
      //.withOutput(new TestWritable("A1"), new Text("A1"))
      .runTest(true); //ordering is important
View Full Code Here


  @Test
  public void testUseOfWritableRegisteredComparator() throws IOException {
    MapReduceDriver<TestWritable, Text, TestWritable, Text, TestWritable, Text> driver = MapReduceDriver
        .newMapReduceDriver(new IdentityMapper<TestWritable, Text>(),
            new IdentityReducer<TestWritable, Text>());
    driver.withInput(new TestWritable("A1"), new Text("A1"))
      .withInput(new TestWritable("A2"), new Text("A2"))
      .withInput(new TestWritable("A3"), new Text("A3"))
      .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
      .withOutput(new TestWritable("A3"), new Text("A3"))
      .withOutput(new TestWritable("A3"), new Text("A2"))
      .withOutput(new TestWritable("A3"), new Text("A1"))
      .runTest(true); //ordering is important
  }
View Full Code Here

    IdentityMapper<TestWritable, Text> identityMapper = new IdentityMapper<TestWritable, Text>();
    IdentityMapper<TestWritable, Text> anotherIdentityMapper = new IdentityMapper<TestWritable, Text>();
    testDriver.addMapper(identityMapper);
    testDriver.addMapper(anotherIdentityMapper);
    testDriver
        .withInput(identityMapper, new TestWritable("A1"), new Text("A1"))
        .withInput(identityMapper, new TestWritable("A2"), new Text("A2"))
        .withInput(identityMapper, new TestWritable("A3"), new Text("A3"))
        .withInput(anotherIdentityMapper, new TestWritable("B1"),
            new Text("B1"))
        .withInput(anotherIdentityMapper, new TestWritable("B2"),
            new Text("B2"))
        .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
        .withOutput(new TestWritable("B2"), new Text("B2"))
        .withOutput(new TestWritable("B2"), new Text("B1"))
        .withOutput(new TestWritable("B2"), new Text("A3"))
        .withOutput(new TestWritable("B2"), new Text("A2"))
        .withOutput(new TestWritable("B2"), new Text("A1")).runTest(true); // ordering
                                                                           // is
                                                                           // important
  }
View Full Code Here

    // to output the keys in reverse order
    MapReduceDriver<TestWritable, Text, TestWritable, Text, TestWritable, Text> driver = MapReduceDriver
        .newMapReduceDriver(new Mapper(), new Reducer());

    driver
        .withInput(new TestWritable("A1"), new Text("A1"))
        .withInput(new TestWritable("A2"), new Text("A2"))
        .withInput(new TestWritable("A3"), new Text("A3"))
        .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
        // these output keys are incorrect because of MRUNIT-129
        // .withOutput(new TestWritable("A3"), new Text("A3"))
        // .withOutput(new TestWritable("A3"), new Text("A2"))
        // .withOutput(new TestWritable("A3"), new Text("A1"))
        // the following are the actual correct outputs
        .withOutput(new TestWritable("A3"), new Text("A3"))
        .withOutput(new TestWritable("A2"), new Text("A2"))
        .withOutput(new TestWritable("A1"), new Text("A1")).runTest(true); // ordering
                                                                           // is
                                                                           // important
  }
View Full Code Here

    Mapper<TestWritable, Text, TestWritable, Text> identityMapper = new Mapper<TestWritable, Text, TestWritable, Text>();
    Mapper<TestWritable, Text, TestWritable, Text> anotherIdentityMapper = new Mapper<TestWritable, Text, TestWritable, Text>();
    testDriver.addMapper(identityMapper);
    testDriver.addMapper(anotherIdentityMapper);
    testDriver
        .withInput(identityMapper, new TestWritable("A1"), new Text("A1"))
        .withInput(identityMapper, new TestWritable("A2"), new Text("A2"))
        .withInput(identityMapper, new TestWritable("A3"), new Text("A3"))
        .withInput(anotherIdentityMapper, new TestWritable("B1"),
            new Text("B1"))
        .withInput(anotherIdentityMapper, new TestWritable("B2"),
            new Text("B2"))
        .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
        .withOutput(new TestWritable("B2"), new Text("B2"))
        .withOutput(new TestWritable("B1"), new Text("B1"))
        .withOutput(new TestWritable("A3"), new Text("A3"))
        .withOutput(new TestWritable("A2"), new Text("A2"))
        .withOutput(new TestWritable("A1"), new Text("A1")).runTest(true); // ordering
                                                                           // is
                                                                           // important
  }
View Full Code Here

  @Test
  public void testUseOfWritableRegisteredComparator() throws IOException {
    MapReduceDriver<TestWritable, Text, TestWritable, Text, TestWritable, Text> driver = MapReduceDriver
        .newMapReduceDriver(new IdentityMapper<TestWritable, Text>(),
            new IdentityReducer<TestWritable, Text>());
    driver.withInput(new TestWritable("A1"), new Text("A1"))
        .withInput(new TestWritable("A2"), new Text("A2"))
        .withInput(new TestWritable("A3"), new Text("A3"))
        .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
        .withOutput(new TestWritable("A3"), new Text("A3"))
        .withOutput(new TestWritable("A3"), new Text("A2"))
        .withOutput(new TestWritable("A3"), new Text("A1")).runTest(true); // ordering
                                                                           // is
                                                                           // important
  }
View Full Code Here

    IdentityMapper<TestWritable, Text> identityMapper = new IdentityMapper<TestWritable, Text>();
    IdentityMapper<TestWritable, Text> anotherIdentityMapper = new IdentityMapper<TestWritable, Text>();
    testDriver.addMapper(identityMapper);
    testDriver.addMapper(anotherIdentityMapper);
    testDriver
        .withInput(identityMapper, new TestWritable("A1"), new Text("A1"))
        .withInput(identityMapper, new TestWritable("A2"), new Text("A2"))
        .withInput(identityMapper, new TestWritable("A3"), new Text("A3"))
        .withInput(anotherIdentityMapper, new TestWritable("B1"),
            new Text("B1"))
        .withInput(anotherIdentityMapper, new TestWritable("B2"),
            new Text("B2"))
        .withKeyGroupingComparator(new TestWritable.SingleGroupComparator())
        .withOutput(new TestWritable("B2"), new Text("B2"))
        .withOutput(new TestWritable("B2"), new Text("B1"))
        .withOutput(new TestWritable("B2"), new Text("A3"))
        .withOutput(new TestWritable("B2"), new Text("A2"))
        .withOutput(new TestWritable("B2"), new Text("A1")).runTest(true); // ordering
                                                                           // is
                                                                           // important
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.mrunit.types.TestWritable$Comparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.