code: public RecordWriter<K, V> getRecordWriter(FileSystem fs, JobConf job,
        String name, Progressable arg3) throws IOException {
  
      final FileSystem myFS = fs;
      final String myName = generateLeafFileName(name);
      final JobConf myJob = job;
      final Progressable myProgressable = arg3;
  
      return new RecordWriter<K, V>() {
  
        // a cache storing the record writers for different output files.
        TreeMap<String, RecordWriter<K, V>> recordWriters = new TreeMap<String, RecordWriter<K, V>>();
  
        public void write(K key, V value) throws IOException {
  
          // get the file name based on the key
          String keyBasedPath = generateFileNameForKeyValue(key, value, myName);
  
          // get the file name based on the input file name
          String finalPath = getInputFileBasedOutputFileName(myJob, keyBasedPath);
  
          // get the actual key
          K actualKey = generateActualKey(key, value);
          V actualValue = generateActualValue(key, value);
  
          RecordWriter<K, V> rw = this.recordWriters.get(finalPath);
          if (rw == null) {
            // if we don't have the record writer yet for the final path, create
            // one
            // and add it to the cache
            rw = getBaseRecordWriter(myFS, myJob, finalPath, myProgressable);
            this.recordWriters.put(finalPath, rw);
          }
          rw.write(actualKey, actualValue);
        };
  
        public void close(Reporter reporter) throws IOException {
          Iterator<String> keys = this.recordWriters.keySet().iterator();
          while (keys.hasNext()) {
            RecordWriter<K, V> rw = this.recordWriters.get(keys.next());
            rw.close(reporter);
          }
          this.recordWriters.clear();
        };
      };
    }
docs: Create a composite record writer that can write key/value data to different
  output files
  
  @param fs
  the file system to use
  @param job
  the job conf for the job
  @param name
  the leaf file name for the output file (such as part-00000")
  @param arg3
  a progressable for reporting progress.
  @return a composite record writer
  @throws IOException