gzip文件如何存储在HDFS中

时间:2016-01-22 18:41:14

标签: algorithm hadoop compression hdfs gzip

HDFS存储支持压缩格式来存储压缩文件。我知道gzip压缩不支持夹板。想象一下,现在该文件是一个压缩大小为1 GB的压缩文件。现在我的问题是:

  1. 此文件将如何存储在HDFS中(块大小为64MB)
  2. 从此link我开始知道gzip格式使用DEFLATE存储压缩数据,DEFLATE将数据存储为一系列压缩块。

    但我无法完全理解它并寻找广泛的解释。

    来自gzip压缩文件的更多疑问:

    1. 这个1GB gzip压缩文件有多少块。
    2. 它会继续使用多个datanode吗?
    3. 复制因子如何适用于此文件(Hadoop群集复制因子为3。)
    4. 什么是DEFLATE算法?
    5. 在阅读gzip压缩文件时应用了哪种算法?
    6. 我在这里看到广泛而详细的解释。

1 个答案:

答案 0 :(得分:1)

  

如果zip文件格式不支持拆分,该文件将如何存储在HDFS中(块大小为64MB)?

所有DFS块都将存储在单个Datanode中。如果块大小为64 MB且文件为1 GB,则Datanode具有16个DFS块(1 GB / 64 MB = 15.625)将存储1 GB文件。

  

这个1GB gzip压缩文件有多少块。

1 GB / 64 MB = 15.625~16 DFS块

  

复制因子如何适用于此文件(Hadoop群集复制因子为3。)

与任何其他文件相同。如果文件是可拆分的,则不做任何更改。如果文件不可拆分,则将标识具有所需块数的Datanode。在这种情况下,3个数据节点有16个可用的DFS块。

从此链接的源代码:http://grepcode.com/file_/repo1.maven.org/maven2/com.ning/metrics.action/0.2.7/org/apache/hadoop/hdfs/server/namenode/ReplicationTargetChooser.java/?v=source

http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.hadoop/hadoop-hdfs/0.22.0/org/apache/hadoop/hdfs/server/namenode/BlockPlacementPolicyDefault.java/?v=source

/** The class is responsible for choosing the desired number of targets
 * for placing block replicas.
 * The replica placement strategy is that if the writer is on a datanode,
 * the 1st replica is placed on the local machine, 
 * otherwise a random datanode. The 2nd replica is placed on a datanode
 * that is on a different rack. The 3rd replica is placed on a datanode
 * which is on the same rack as the first replca.
 */
  

什么是DEFLATE算法?

DELATE是解压缩GZIP格式压缩文件的算法。

查看此幻灯片,了解不同zip文件变体的其他算法。

enter image description here enter image description here

有关详细信息,请查看此presentation