zoukankan      html  css  js  c++  java
  • hive基本操作与应用

    通过hadoop上的hive完成WordCount

    start-all.sh
    

      

    启动hadoop

    hdfs dfs -mkdir songinput
    hdfs dfs -ls /user/hadoop

    Hdfs上创建文件夹

    cd ~/hadoop
    ls

    上传文件至hdfs

    hdfs dfs -put ./songs.txt songinput
    hdfs dfs -ls /user/hadoop/songinput

    启动Hive

    hive

    创建原始文档表

    create table docs(line string);<br>show tables;

    导入文件内容到表docs并查看

    load data inpath '/user/hadoop/songinput/songs.txt' overwrite into table docs;<br>select * from docs;

    用HQL进行词频统计,结果放在表word_count里

    create table word_count as select word,count(1) from (select explode(split(line,' ')) as word from docs) word group by word;

    查看统计结果

    select * from word_count;

  • 相关阅读:
    HDU 4005 The war
    #undef
    [转载] #define new DEBUG_NEW
    [转载]常用正则表达式
    [百科]
    [转载]
    [转载]
    [转载]
    [百科]
    [转载]VC6中的文件后缀
  • 原文地址:https://www.cnblogs.com/tyx123/p/9048661.html
Copyright © 2011-2022 走看看