/**
   * Test characteristic set reduction
   *
   * @throws IOException
   */
  @Test
  public void characteristic_set_reducer_06() throws IOException {
    MapReduceDriver<
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            NullWritable>
        driver = this.getMapReduceDriver();

    this.createSet(driver, 2, 1, "http://predicate", "http://other");
    this.createSet(driver, 1, 1, "http://other");
    driver.runTest(false);

    driver = getMapReduceDriver();
    createSet(driver, 2, 1, "http://predicate", "http://other");
    createSet(driver, 1, 1, "http://other");
    List<Pair<CharacteristicSetWritable, NullWritable>> results = driver.run();
    for (Pair<CharacteristicSetWritable, NullWritable> pair : results) {
      CharacteristicSetWritable cw = pair.getFirst();
      boolean expectTwo = cw.hasCharacteristic("http://predicate");
      Assert.assertEquals(expectTwo ? 2 : 1, cw.getCount().get());
    }
  }
Пример #2
0
  @org.testng.annotations.Test(groups = {"fast"})
  public void sortUsagesTest() throws ParseException {
    mapReduceDriver.addInput(new Text(RES1_ID), new LongWritable(COUNT1));
    mapReduceDriver.addInput(new Text(RES2_ID), new LongWritable(COUNT2));
    mapReduceDriver.addInput(new Text(RES3_ID), new LongWritable(COUNT3));

    MostPopularProtos.MostPopularStats.Builder statsBuilder =
        MostPopularProtos.MostPopularStats.newBuilder();
    statsBuilder.setTimestamp(new SimpleDateFormat("yyyy-MM-dd").parse(TEST_DATE).getTime());

    MostPopularProtos.ResourceStat.Builder resourceStatBuilder =
        MostPopularProtos.ResourceStat.newBuilder();
    resourceStatBuilder.setCounter(COUNT3);
    resourceStatBuilder.setResourceId(RES3_ID);
    statsBuilder.addStat(resourceStatBuilder);

    resourceStatBuilder = MostPopularProtos.ResourceStat.newBuilder();
    resourceStatBuilder.setCounter(COUNT1);
    resourceStatBuilder.setResourceId(RES1_ID);
    statsBuilder.addStat(resourceStatBuilder);

    BytesWritable expectedOutput = new BytesWritable(statsBuilder.build().toByteArray());

    mapReduceDriver.addOutput(NullWritable.get(), expectedOutput);

    mapReduceDriver.runTest();
  }
  /**
   * Test characteristic set reduction
   *
   * @throws IOException
   */
  @Test
  public void characteristic_set_reducer_01() throws IOException {
    MapReduceDriver<
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            NullWritable>
        driver = this.getMapReduceDriver();

    this.createSet(driver, 1, 1, "http://predicate");

    driver.runTest(false);
  }
 @Test
 public void testMapperReducer() throws IOException {
   mapReduceDriver.withInput(
       new LongWritable(),
       new Text(
           "Wed Apr 24 23:04:58 2013 [SESSION 2954383360]: Scanning path '/Users/komamitsu/Library/Caches/com.avast.registration/Cache.db' started."));
   mapReduceDriver.withInput(
       new LongWritable(),
       new Text(
           "Wed Apr 25 23:04:58 2013 [SESSION 2954383360]: Scanning path '/Users/komamitsu/Library/Caches/com.avast.registration/Cache.db' started."));
   mapReduceDriver.withInput(
       new LongWritable(),
       new Text(
           "Wed Apr 24 23:04:58 2013 [SESSION 2954383360]: Scanning path '/Users/komamitsu/Library/Caches/com.avast.registration/Cache.db' started."));
   mapReduceDriver.withOutput(new Text("Apr 24"), new LongWritable(2));
   mapReduceDriver.withOutput(new Text("Apr 25"), new LongWritable(1));
   mapReduceDriver.runTest();
 }
Пример #5
0
  @Test
  public void testMapReduce() throws IOException {
    mapRedDriver.withInput(new LongWritable(1), new Text("Marco-Fabio,Luca,Gordon"));
    mapRedDriver.withInput(new LongWritable(2), new Text("Fabio-Nathalia,Marco,Luca,Gordon"));
    mapRedDriver.withInput(new LongWritable(3), new Text("Luca-Nathalia,Marco,Fabio"));
    mapRedDriver.withInput(new LongWritable(4), new Text("Nathalia-Fabio,Luca"));
    mapRedDriver.withInput(new LongWritable(5), new Text("Gordon-Marco,Fabio"));

    mapRedDriver.withAllOutput(
        Arrays.asList(
            new Pair<>(new Text("Gordon"), new Text("Luca(2:[Marco, Fabio]),Nathalia(1:[Fabio])")),
            new Pair<>(new Text("Luca"), new Text("Gordon(2:[Marco, Fabio])")),
            new Pair<>(new Text("Marco"), new Text("Nathalia(2:[Fabio, Luca])")),
            new Pair<>(
                new Text("Nathalia"), new Text("Marco(2:[Fabio, Luca]),Gordon(1:[Fabio])"))));

    mapRedDriver.runTest();
  }
  /**
   * Test characteristic set reduction
   *
   * @throws IOException
   */
  @Test
  public void characteristic_set_reducer_02() throws IOException {
    MapReduceDriver<
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            CharacteristicSetWritable,
            NullWritable>
        driver = this.getMapReduceDriver();

    this.createSet(driver, 2, 1, "http://predicate");
    driver.runTest(false);

    driver = getMapReduceDriver();
    createSet(driver, 2, 1, "http://predicate");
    List<Pair<CharacteristicSetWritable, NullWritable>> results = driver.run();
    CharacteristicSetWritable cw = results.get(0).getFirst();
    Assert.assertEquals(2, cw.getCount().get());
  }
 @Test
 public void testMapReduce() throws IOException {
   mapReduceDriver.withInput(new LongWritable(0), inputFilePath);
   mapReduceDriver.addOutput(new LongWritable(0), new Text(outputdir.toString() + "\n"));
   mapReduceDriver.runTest();
 }
Пример #8
0
 @Test
 public void testMapReduce() throws IOException {
   mapReduceDriver.withInput(new LongWritable(), new Text(INPUT_LINE));
   mapReduceDriver.withOutput(new Text("ip1"), new AggregatedValue(40028, 40028));
   mapReduceDriver.runTest();
 }