Example usage for org.apache.hadoop.mapreduce.lib.partition HashPartitioner HashPartitioner

List of usage examples for org.apache.hadoop.mapreduce.lib.partition HashPartitioner HashPartitioner

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.lib.partition HashPartitioner HashPartitioner.

Prototype

HashPartitioner

Source Link

Usage

From source file:org.apache.blur.utils.TableShardCountCollapserTest.java

License:Apache License

private static void createShard(Configuration configuration, int i, Path path, int totalShardCount)
        throws IOException {
    HdfsDirectory hdfsDirectory = new HdfsDirectory(configuration, path);
    IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_43, new KeywordAnalyzer());
    TieredMergePolicy mergePolicy = (TieredMergePolicy) conf.getMergePolicy();
    mergePolicy.setUseCompoundFile(false);
    IndexWriter indexWriter = new IndexWriter(hdfsDirectory, conf);

    Partitioner<IntWritable, IntWritable> partitioner = new HashPartitioner<IntWritable, IntWritable>();
    int partition = partitioner.getPartition(new IntWritable(i), null, totalShardCount);
    assertEquals(i, partition);//from w  w w  .  ja v  a2s . c o  m

    Document doc = getDoc(i);
    indexWriter.addDocument(doc);
    indexWriter.close();
}