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

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

      storageHandler.configureOutputJobProperties(tableDesc, jobProperties);

      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);
    }
  }
예제 #2
0
  public static Map<String, String> getInputJobProperties(
      HCatStorageHandler storageHandler, InputJobInfo inputJobInfo) {
    TableDesc tableDesc =
        new TableDesc(
            storageHandler.getSerDeClass(),
            storageHandler.getInputFormatClass(),
            storageHandler.getOutputFormatClass(),
            inputJobInfo.getTableInfo().getStorerInfo().getProperties());
    if (tableDesc.getJobProperties() == null) {
      tableDesc.setJobProperties(new HashMap<String, String>());
    }

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

      storageHandler.configureInputJobProperties(tableDesc, jobProperties);

    } catch (IOException e) {
      throw new IllegalStateException("Failed to configure StorageHandler", e);
    }

    return jobProperties;
  }