Hadoop I/O

- checksum, CRC-32C, for every 512 bits, 

  • write, last datanode of the pipeline verifies checksum
  • read, block verification on client read
  • rawlocalfilesystem, to disable checksum

- compression, (default is DefaultCodec, DEFLATE)

  • splittable compression for mapreduce, bzip2. also sequence file, avro file or parquet file
  • CompressionCodec interface for all compression types
CompressionCodec compc = (CompressionCodec)ReflectionUtils.newInstance(
				Class.forName(compressClassname), cfg);
CompressionCodecFactory ccf = new CompressionCodecFactory(cfg);
CompressionCodec cc = ccf.getCodec(pp); // by filename extension

  • mapreduce output compression, compression type for sequence file output, RECORD or BLOCK
FileOutputFormat.setCompressOutput(job, true);
FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class);

  • map output can also be compressed to save network traffic
Configuration conf = new Configuration();
conf.setBoolean(Job.MAP_OUTPUT_COMPRESS, true);
conf.setClass(Job.MAP_OUTPUT_COMPRESS_CODEC, GzipCodec.class,
CompressionCodec.class);

- serialisation for inter process communication and persistent storage

  • serialisation format, needs to be compact, fast, extensible and interoperable
  • one of the formats, Writable
public interface Writable {
    void write(DataOutput out) throws IOException;
    void readFields(DataInput in) throws IOException;
}
  • Text is 
  1. UTF-8,
  2.  t.length is length of underlying bytes . 
  3. mutable, getbytes.length may be different from t.getLength
  • Custom Writable, WritableComparator, RawComparator, 
static {
WritableComparator.define(TextPair.class, new Comparator());
}
  • Serialization Framework, Serialization interface, WritableSerialization and Avro Serialization are supported out of the box

 - File-based data structure

  • Sequence File, binary key-value pairs, also as a container for multiple small files.

record and block compression.



  • Map File (index for fast lookup. map entries need to be added in order)

index is fraction of keys to be loaded to memory

main data file contains all map entries in sorted key order. 

  • sequence file, map file and avro file are row-oriented format.  column-oriented can skip unwanted columns.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值