Hadoop的MapFile, SetFile, ArrayFile 及 BloomMapFile文件格式<转>
来源:互联网 发布:网络大专报名 编辑:程序博客网 时间:2024/05/22 07:50
SequenceFile 是Hadoop 的一个基础数据文件格式,后续讲的 MapFile, SetFile, ArrayFile 及 BloomMapFile 都是基于它来实现的。
- MapFile – 一个key-value 对应的查找数据结构,由数据文件/data 和索引文件 /index 组成,数据文件中包含所有需要存储的key-value对,按key的顺序排列。索引文件包含一部分key值,用以指向数据文件的关键位置。
- SetFile – 基于 MapFile 实现的,他只有key,value为不可变的数据。
- ArrayFile – 也是基于 MapFile 实现,他就像我们使用的数组一样,key值为序列化的数字。
- BloomMapFile – 他在 MapFile 的基础上增加了一个 /bloom 文件,包含的是二进制的过滤表,在每一次写操作完成时,会更新这个过滤表
7.值得提一下binary stream with zero-compressed encoding
/** * Serializes a long to a binary stream with zero-compressed encoding. * For -112 <= i <= 127, only one byte is used with the actual value. * For other values of i, the first byte value indicates whether the * long is positive or negative, and the number of bytes that follow. * If the first byte value v is between -113 and -120, the following long * is positive, with number of bytes that follow are -(v+112). * If the first byte value v is between -121 and -128, the following long * is negative, with number of bytes that follow are -(v+120). Bytes are * stored in the high-non-zero-byte-first order. * * @param stream Binary output stream * @param i Long to be serialized * @throws java.io.IOException */ /* * 将一个long类型的i,写入输出流DataOutput中 * 如果 -112 <= i <= 127,只使用一个byte表示i并写入输出流中 * 第一个字节表示i的正负和接下来表示i的字节数 * 如果第一个字节-113 <= v <= -120,那么i是正数,并且接下来i占的字节数是-(v+112)(也就是1到8个字节之间) * 如果第一个字节-121 <= v <= -128,那么i是负数,并且接下来的i占的字节数是-(v+120)(也就是1到8个字节之间) * 写入时先写i的高位,再写低位 * */ public static void writeVLong(DataOutput stream, long i) throws IOException { if (i >= -112 && i <= 127) { stream.writeByte((byte)i); return; } int len = -112; if (i < 0) { i ^= -1L; // take one's complement' len = -120; } long tmp = i; while (tmp != 0) { tmp = tmp >> 8; len--; } stream.writeByte((byte)len); len = (len < -120) ? -(len + 120) : -(len + 112); for (int idx = len; idx != 0; idx--) { int shiftbits = (idx - 1) * 8; long mask = 0xFFL << shiftbits; stream.writeByte((byte)((i & mask) >> shiftbits)); } }
这种编码方式的有点是照顾了绝大多数能够使用一个byte编码的数字,最大的缺点是,两个byte所能编码的数字少了很多,并且两个byte以上长度的编码效率都下降了。
- Hadoop的MapFile, SetFile, ArrayFile 及 BloomMapFile文件格式<转>
- MapFile和BloomMapFile文件
- MapFile和BloomMapFile文件
- MapFile和BloomMapFile文件
- Hadoop中sequencefile和mapfile的区别
- Hadoop中的SequenceFile和MapFile
- Hadoop的文件格式
- Hadoop Distributed Cache 共享archives时的问题(以MapFile的共享为例)
- 在Hadoop中,从MapFile文件中读取指定键值的元素
- 在Hadoop中,从MapFile文件中读取指定键值的元素
- Hadoop HDFS之SequenceFile和MapFile
- Hadoop HDFS之SequenceFile和MapFile
- Hadoop HDFS之SequenceFile和MapFile
- Hadoop HDFS之SequenceFile和MapFile
- (转)hadoop多文件格式输入
- Hadoop文件格式
- Hadoop文件格式
- Hadoop文件格式
- MATLAB在Ubuntu下配置到applications menu
- 顺序表的应用举例
- Mahout实例(UserCF,ItermCF,SlopOne)
- dbgrideh使用
- 结构体指针数组 vs 结构体数组
- Hadoop的MapFile, SetFile, ArrayFile 及 BloomMapFile文件格式<转>
- 单链表的应用举例
- js使 input file获得焦点,并且清空该值。
- 百度地图SDK集成搜索服务
- 游戏开发入门
- 百度地图API新版申请API Key
- 详解大端模式和小端模式
- 1. 初识Deep Learning
- 15条 linux Find 命令实际使用方法