Examples of UrlOnlyPartitioner


Examples of org.apache.nutch.crawl.UrlWithScore.UrlOnlyPartitioner

    in.close();
    out.close();
  }
 
  public void testPartitioner() throws IOException {
    UrlOnlyPartitioner part = new UrlOnlyPartitioner();
   
    UrlWithScore k1 = new UrlWithScore("http://example.org/1", 1f);
    UrlWithScore k2 = new UrlWithScore("http://example.org/1", 2f);
    UrlWithScore k3 = new UrlWithScore("http://example.org/2", 1f);
    UrlWithScore k4 = new UrlWithScore("http://example.org/2", 2f);
    UrlWithScore k5 = new UrlWithScore("http://example.org/2", 3f);
   
    int numReduces = 7;
   
    // keys 1 and 2 should be partitioned together
    int partForKey1 = part.getPartition(k1, null, numReduces);
    assertEquals(partForKey1, part.getPartition(k2, null, numReduces));
    assertEquals(partForKey1, part.getPartition(k2, null, numReduces));
   
    // keys 3, 4 and 5 should be partitioned together
    int partForKey3 = part.getPartition(k3, null, numReduces);
    assertEquals(partForKey3, part.getPartition(k4, null, numReduces));
    assertEquals(partForKey3, part.getPartition(k5, null, numReduces));
  }
View Full Code Here

Examples of org.apache.nutch.crawl.UrlWithScore.UrlOnlyPartitioner

    out.close();
  }
 
  @Test
  public void testPartitioner() throws IOException {
    UrlOnlyPartitioner part = new UrlOnlyPartitioner();
   
    UrlWithScore k1 = new UrlWithScore("http://example.org/1", 1f);
    UrlWithScore k2 = new UrlWithScore("http://example.org/1", 2f);
    UrlWithScore k3 = new UrlWithScore("http://example.org/2", 1f);
    UrlWithScore k4 = new UrlWithScore("http://example.org/2", 2f);
    UrlWithScore k5 = new UrlWithScore("http://example.org/2", 3f);
   
    int numReduces = 7;
   
    // keys 1 and 2 should be partitioned together
    int partForKey1 = part.getPartition(k1, null, numReduces);
    assertEquals(partForKey1, part.getPartition(k2, null, numReduces));
    assertEquals(partForKey1, part.getPartition(k2, null, numReduces));
   
    // keys 3, 4 and 5 should be partitioned together
    int partForKey3 = part.getPartition(k3, null, numReduces);
    assertEquals(partForKey3, part.getPartition(k4, null, numReduces));
    assertEquals(partForKey3, part.getPartition(k5, null, numReduces));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.