Ejemplo n.º 1
0
 /**
  * 圧縮の種類を取得する。
  *
  * @param strCompType CompressionTypeの文字列
  * @return CompressionType
  */
 protected CompressionType getCompType(String strCompType) {
   CompressionType compType = null;
   try {
     compType = CompressionType.valueOf(strCompType);
   } catch (Exception e) {
     compType = CompressionType.NONE;
     LOG.warn("TG-EXTRACTOR-02004", strCompType);
   }
   return compType;
 }
 public static RecordWriter getHiveRecordWriter(
     JobConf jc,
     TableDesc tableInfo,
     Class<? extends Writable> outputClass,
     FileSinkDesc conf,
     Path outPath)
     throws HiveException {
   try {
     HiveOutputFormat<?, ?> hiveOutputFormat = tableInfo.getOutputFileFormatClass().newInstance();
     boolean isCompressed = conf.getCompressed();
     JobConf jc_output = jc;
     if (isCompressed) {
       jc_output = new JobConf(jc);
       String codecStr = conf.getCompressCodec();
       if (codecStr != null && !codecStr.trim().equals("")) {
         Class<? extends CompressionCodec> codec =
             (Class<? extends CompressionCodec>) Class.forName(codecStr);
         FileOutputFormat.setOutputCompressorClass(jc_output, codec);
       }
       String type = conf.getCompressType();
       if (type != null && !type.trim().equals("")) {
         CompressionType style = CompressionType.valueOf(type);
         SequenceFileOutputFormat.setOutputCompressionType(jc, style);
       }
     }
     return getRecordWriter(
         jc_output,
         hiveOutputFormat,
         outputClass,
         isCompressed,
         tableInfo.getProperties(),
         outPath);
   } catch (Exception e) {
     throw new HiveException(e);
   }
 }