当前位置: 首页>>代码示例>>Java>>正文


Java CodecMap类代码示例

本文整理汇总了Java中com.cloudera.sqoop.io.CodecMap的典型用法代码示例。如果您正苦于以下问题:Java CodecMap类的具体用法?Java CodecMap怎么用?Java CodecMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CodecMap类属于com.cloudera.sqoop.io包,在下文中一共展示了CodecMap类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCodec

import com.cloudera.sqoop.io.CodecMap; //导入依赖的package包/类
private static CompressionCodec getCodec(Configuration conf,
    SqoopOptions options) throws IOException {
  if (options.shouldUseCompression()) {
    if (options.getCompressionCodec() == null) {
      return new GzipCodec();
    } else {
      return CodecMap.getCodec(options.getCompressionCodec(), conf);
    }
  }
  return null;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:12,代码来源:DirectImportUtils.java

示例2: configureOutputFormat

import com.cloudera.sqoop.io.CodecMap; //导入依赖的package包/类
/**
 * Configure the output format to use for the job.
 */
@Override
protected void configureOutputFormat(Job job, String tableName,
    String tableClassName) throws ClassNotFoundException, IOException {

  job.setOutputFormatClass(getOutputFormatClass());

  if (isHCatJob) {
    LOG.debug("Configuring output format for HCatalog  import job");
    SqoopHCatUtilities.configureImportOutputFormat(options, job,
      getContext().getConnManager(), tableName, job.getConfiguration());
    return;
  }

  if (options.getFileLayout() == SqoopOptions.FileLayout.SequenceFile) {
    job.getConfiguration().set("mapred.output.value.class", tableClassName);
  }

  if (options.shouldUseCompression()) {
    FileOutputFormat.setCompressOutput(job, true);

    String codecName = options.getCompressionCodec();
    Class<? extends CompressionCodec> codecClass;
    if (codecName == null) {
      codecClass = GzipCodec.class;
    } else {
      Configuration conf = job.getConfiguration();
      codecClass = CodecMap.getCodec(codecName, conf).getClass();
    }
    FileOutputFormat.setOutputCompressorClass(job, codecClass);

    if (options.getFileLayout() == SqoopOptions.FileLayout.SequenceFile) {
      SequenceFileOutputFormat.setOutputCompressionType(job,
        CompressionType.BLOCK);
    }

    // SQOOP-428: Avro expects not a fully qualified class name but a "short"
    // name instead (e.g. "snappy") and it needs to be set in a custom
    // configuration option called "avro.output.codec".
    // The default codec is "deflate".
    if (options.getFileLayout() == SqoopOptions.FileLayout.AvroDataFile) {
      if (codecName != null) {
        String shortName =
          CodecMap.getCodecShortNameByName(codecName, job.getConfiguration());
        // Avro only knows about "deflate" and not "default"
        if (shortName.equalsIgnoreCase("default")) {
          shortName = "deflate";
        }
        job.getConfiguration().set(AvroJob.OUTPUT_CODEC, shortName);
      } else {
        job.getConfiguration()
          .set(AvroJob.OUTPUT_CODEC, DataFileConstants.DEFLATE_CODEC);
      }
    }
  }

  Path outputPath = context.getDestination();
  FileOutputFormat.setOutputPath(job, outputPath);
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:62,代码来源:ImportJobBase.java

示例3: configureOutputFormat

import com.cloudera.sqoop.io.CodecMap; //导入依赖的package包/类
/**
 * Configure the output format to use for the job.
 */
@Override
protected void configureOutputFormat(Job job, String tableName,
    String tableClassName) throws ClassNotFoundException, IOException {

  job.setOutputFormatClass(getOutputFormatClass());

  if (options.getFileLayout() == SqoopOptions.FileLayout.SequenceFile) {
    job.getConfiguration().set("mapred.output.value.class", tableClassName);
  }

  if (options.shouldUseCompression()) {
    FileOutputFormat.setCompressOutput(job, true);

    String codecName = options.getCompressionCodec();
    Class<? extends CompressionCodec> codecClass;
    if (codecName == null) {
      codecClass = GzipCodec.class;
    } else {
      Configuration conf = job.getConfiguration();
      codecClass = CodecMap.getCodec(codecName, conf).getClass();
    }
    FileOutputFormat.setOutputCompressorClass(job, codecClass);

    if (options.getFileLayout() == SqoopOptions.FileLayout.SequenceFile) {
      SequenceFileOutputFormat.setOutputCompressionType(job,
        CompressionType.BLOCK);
    }

    // SQOOP-428: Avro expects not a fully qualified class name but a "short"
    // name instead (e.g. "snappy") and it needs to be set in a custom
    // configuration option called "avro.output.codec".
    // The default codec is "deflate".
    if (options.getFileLayout() == SqoopOptions.FileLayout.AvroDataFile) {
      if (codecName != null) {
        String shortName =
          CodecMap.getCodecShortNameByName(codecName, job.getConfiguration());
        // Avro only knows about "deflate" and not "default"
        if (shortName.equalsIgnoreCase("default")) {
          shortName = "deflate";
        }
        job.getConfiguration().set(AvroJob.OUTPUT_CODEC, shortName);
      } else {
        job.getConfiguration()
          .set(AvroJob.OUTPUT_CODEC, DataFileConstants.DEFLATE_CODEC);
      }
    }
  }

  Path outputPath = context.getDestination();
  FileOutputFormat.setOutputPath(job, outputPath);
}
 
开发者ID:infinidb,项目名称:sqoop,代码行数:55,代码来源:ImportJobBase.java


注:本文中的com.cloudera.sqoop.io.CodecMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。