V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
anonymoustian
V2EX  ›  Hadoop

Hive 可以知道数据有多大吗?

  •  
  •   anonymoustian · 2016-04-26 23:24:00 +08:00 · 3451 次点击
    这是一个创建于 2920 天前的主题,其中的信息可能已经有所发展或是发生改变。

    是这样,接手了别人的一个项目。 Hive 表结构大概有 17 亿条数据。

    我知道 hive 的存储是放到 HDFS 上的 /usr/hive/warehouse 目录下

    但是因为它之前的数据是做了分区的,还有 hdfs 本来就是冗余存储 所以就会是这样

    /usr/hive/warehouse/dbname/tablename/hour=01/part00000001copy /usr/hive/warehouse/dbname/tablename/hour=01/part00000001 /usr/hive/warehouse/dbname/tablename/hour=02/part00000001copy

    大概类似上面的效果

    而且 HDFS 上的目录的文件是不显示大小的。

    因为要做项目的数据评估 效率分析之类的, 如何才能知道 这 17 亿条数据的数据大小呢?

    4 条回复    2016-04-28 00:50:53 +08:00
    cxzl25
        1
    cxzl25  
       2016-04-27 00:19:25 +08:00   ❤️ 1
    可用
    hdfs dfs -help du

    -du [-s] [-h] <path> ...: Show the amount of space, in bytes, used by the files that
    match the specified file pattern. The following flags are optional:
    -s Rather than showing the size of each individual file that
    matches the pattern, shows the total (summary) size.
    -h Formats the sizes of files in a human-readable fashion
    rather than a number of bytes.

    Note that, even without the -s option, this only shows size summaries
    one level deep into a directory.
    The output is in the form
    size name(full path)


    另 一般 hive 计算完毕,日志会显示
    stats: [numFiles=1, numRows=62xx9xx, totalSize=83xx236xx, rawDataSize=81x49xxx]


    且有如下语法,对部分计算过产生的分区,可以统计大小

    ANALYZE TABLE tablename [PARTITION(partcol1[=val1], partcol2[=val2], ...)] COMPUTE STATISTICS [noscan];

    参考 : https://cwiki.apache.org/confluence/display/Hive/StatsDev
    firstway
        2
    firstway  
       2016-04-27 06:45:05 +08:00 via Android   ❤️ 1
    楼上对的。
    使用 du ,你可以查看整个数据文件大小。但是这个不能告诉你 record 的条数。一般文件是压缩过的(不压缩太费空间).
    不知道你说大小是指什么?目的是什么?是想预测处理速度?这个不光看数据规模,还要看数据可分的细度,还有集群的处理能力。。。。
    anonymoustian
        3
    anonymoustian  
    OP
       2016-04-27 09:47:52 +08:00
    @firstway 是这样的, 要给客户做系统性能的汇报~
    firstway
        4
    firstway  
       2016-04-28 00:50:53 +08:00 via Android   ❤️ 2
    hive 最终是以 MapReduce 的 job 来运行的,所以你可以在 copy 几个小时,几天,几周的数据跑一下你们的 job 。如果你数据分布比较均匀,处理速度接近线性。
    如果接近线性,就好估计整体处理时间了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4678 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 10:02 · PVG 18:02 · LAX 03:02 · JFK 06:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.