org.apache.hadoop.mapreduce.lib.partition

## Class InputSampler<K,V>

- java.lang.Object
- - org.apache.hadoop.conf.Configured
  - - org.apache.hadoop.mapreduce.lib.partition.InputSampler<K,V>

- All Implemented Interfaces:
    Configurable, Tool
  Direct Known Subclasses:
    InputSampler

      @InterfaceAudience.Public
       @InterfaceStability.Stable
      public class InputSampler<K,V>
      extends Configured
      implements Tool

  Utility for collecting samples and writing a partition file for `TotalOrderPartitioner`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InputSampler(Configuration conf)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(String[] args)`
    `int` | `run(String[] args)` Driver for InputSampler from the command line.
    `static <K,V> void` | `writePartitionFile(Job job, org.apache.hadoop.mapreduce.lib.partition.InputSampler.Sampler<K,V> sampler)` Write a partition file for the given job, using the Sampler provided.

    - ### Methods inherited from class org.apache.hadoop.conf.Configured

      `getConf, setConf`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.hadoop.conf.Configurable

      `getConf, setConf`

- - ### Constructor Detail

    - #### InputSampler

          public InputSampler(Configuration conf)

  - ### Method Detail

    - #### writePartitionFile

          public static <K,V> void writePartitionFile(Job job,
                                                      org.apache.hadoop.mapreduce.lib.partition.InputSampler.Sampler<K,V> sampler)
                                               throws IOException,
                                                      ClassNotFoundException,
                                                      InterruptedException

      Write a partition file for the given job, using the Sampler provided. Queries the sampler for a sample keyset, sorts by the output key comparator, selects the keys for each rank, and writes to the destination returned from `TotalOrderPartitioner.getPartitionFile(org.apache.hadoop.conf.Configuration)`.
      Throws:
        `IOException`
        `ClassNotFoundException`
        `InterruptedException`

    - #### run

          public int run(String[] args)
                  throws Exception

      Driver for InputSampler from the command line. Configures a JobConf instance and calls `writePartitionFile(org.apache.hadoop.mapreduce.Job, org.apache.hadoop.mapreduce.lib.partition.InputSampler.Sampler<K, V>)`.
      Specified by:
        `run` in interface `Tool`
      Parameters:
        `args` - command specific arguments.
      Returns:
        exit code.
      Throws:
        `Exception`

    - #### main

          public static void main(String[] args)
                           throws Exception

      Throws:
        `Exception`

Copyright © 2022 Apache Software Foundation. All rights reserved.