@InterfaceAudience.Private
  @InterfaceStability.Evolving
  public static void
  configureOutputStorageHandler(HiveStorageHandler storageHandler,
                  Configuration conf,
                  OutputJobInfo outputJobInfo) {
    //TODO replace IgnoreKeyTextOutputFormat with a
    //HiveOutputFormatWrapper in StorageHandler
    Properties props = outputJobInfo.getTableInfo().getStorerInfo().getProperties();
    props.put(serdeConstants.SERIALIZATION_LIB,storageHandler.getSerDeClass().getName());
    TableDesc tableDesc = new TableDesc(storageHandler.getInputFormatClass(),
      IgnoreKeyTextOutputFormat.class,props);
    if (tableDesc.getJobProperties() == null)
      tableDesc.setJobProperties(new HashMap<String, String>());
    for (Map.Entry<String, String> el : conf) {
      tableDesc.getJobProperties().put(el.getKey(), el.getValue());
    }

    Properties mytableProperties = tableDesc.getProperties();
    mytableProperties.setProperty(
        org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_NAME,
        outputJobInfo.getDatabaseName()+ "." + outputJobInfo.getTableName());

    Map<String, String> jobProperties = new HashMap<String, String>();
    try {
      tableDesc.getJobProperties().put(
        HCatConstants.HCAT_KEY_OUTPUT_INFO,
        HCatUtil.serialize(outputJobInfo));

      storageHandler.configureOutputJobProperties(tableDesc,
        jobProperties);

      Map<String, String> tableJobProperties = tableDesc.getJobProperties();
      if (tableJobProperties != null) {
        if (tableJobProperties.containsKey(HCatConstants.HCAT_KEY_OUTPUT_INFO)) {
          String jobString = tableJobProperties.get(HCatConstants.HCAT_KEY_OUTPUT_INFO);
          if (jobString != null) {
            if  (!jobProperties.containsKey(HCatConstants.HCAT_KEY_OUTPUT_INFO)) {
              jobProperties.put(HCatConstants.HCAT_KEY_OUTPUT_INFO,
                  tableJobProperties.get(HCatConstants.HCAT_KEY_OUTPUT_INFO));
            }
          }
        }
      }
      for (Map.Entry<String, String> el : jobProperties.entrySet()) {
        conf.set(el.getKey(), el.getValue());
      }
    } catch (IOException e) {
      throw new IllegalStateException(
        "Failed to configure StorageHandler", e);
    }
  }
Create an instance of a storage handler. If storageHandler == null,
then surrrogate StorageHandler is used to encapsulate the InputFormat, OutputFormat and SerDe.
This StorageHandler assumes the other supplied storage artifacts are for a file-based storage system.
@param conf job's configuration will be used to configure the Configurable StorageHandler
@param storageHandler fully qualified class name of the desired StorageHandle instance
@param serDe fully qualified class name of the desired SerDe instance
@param inputFormat fully qualified class name of the desired InputFormat instance
@param outputFormat fully qualified class name of the desired outputFormat instance
@return storageHandler instance
@throws IOException
hcatalog/core/src/main/java/org/apache/hive/hcatalog/common/HCatUtil.java