Hive Word count
--https://github.com/slimandslam/pig-hive-wordcount/blob/master/wordcount.hql
DROP TABLE myinput;
DROP TABLE wordcount;
CREATE TABLE myinput (line STRING);
-- Load the text from the local (Linux) filesystem. This should be changed to HDFS
-- for any serious usage
LOAD DATA LOCAL INPATH '/home/username/mytext.txt' INTO TABLE myinput;
-- Create a table with the words cleaned and counted.
-- The Java regex removes all punctuation and control characters.
---reference http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
CREATE TABLE wordcount AS
SELECT word, count(1) AS count
FROM (
SELECT EXPLODE(SPLIT(LOWER(REGEXP_REPLACE(line,'[\\p{Punct},\\p{Cntrl}]','')),' '))
AS word FROM myinput
) words
GROUP BY word
-- Sort the output by count with the highest counts first
ORDER BY count DESC, word ASC;
-- Make the output look like the output of the Pig DUMP function
-- so that we can diff this output with the Pig wordcount output
SELECT CONCAT_WS(',', CONCAT("\(",word), CONCAT(count,"\)")) FROM wordcount;
--EXPLODE is a udtf function, used to convert each element in the array to a row.
Hive Word count的更多相关文章
- [Hive_add_6] Hive 实现 Word Count
0. 说明 Hive 通过 explode()函数 和 split()函数 实现 WordConut 1. Hive 实现 Word Count 方式一 1.1 思路 将每一行文本变为 Array 数 ...
- mac上eclipse上运行word count
1.打开eclipse之后,建立wordcount项目 package wordcount; import java.io.IOException; import java.util.StringTo ...
- MapReduce工作机制——Word Count实例(一)
MapReduce工作机制--Word Count实例(一) MapReduce的思想是分布式计算,也就是分而治之,并行计算提高速度. 编程思想 首先,要将数据抽象为键值对的形式,map函数输入键值对 ...
- Word Count作业
Word Count作业 一.个人Gitee地址:https://gitee.com/Changyu-Guo 二.项目简介 该项目主要是模拟Linux上面的wc命令,基本要求如下: 命令格式: wc. ...
- Word Count
Word Count 一.个人Gitee地址:https://gitee.com/godcoder979/(该项目完整代码在这里) 二.项目简介: 该项目是一个统计文件字符.单词.行数等数目的应用程序 ...
- Mac下hadoop运行word count的坑
Mac下hadoop运行word count的坑 Word count体现了Map Reduce的经典思想,是分布式计算中中的hello world.然而博主很幸运地遇到了Mac下特有的问题Mkdir ...
- [MapReduce_1] 运行 Word Count 示例程序
0. 说明 MapReduce 实现 Word Count 示意图 && Word Count 代码编写 1. MapReduce 实现 Word Count 示意图 1. Map:预 ...
- 【2016.3.22】作业 Word count 小程序
今天更下word count程序的设计思路及实现方法. 我的程序贴在coding里,这里就先不贴出来了, 我的coding地址:https://coding.net/u/holy_angel/p/wo ...
- 软件工程第三个程序:“WC项目” —— 文件信息统计(Word Count ) 命令行程序
软件工程第三个程序:“WC项目” —— 文件信息统计(Word Count ) 命令行程序 格式:wc.exe [parameter][filename] 在[parameter]中,用户通过输入参数 ...
随机推荐
- WebApi传参总动员(四)
前文介绍了Form Data 形式传参,本文介绍json传参. WebApi及Model: public class ValuesController : ApiController { [HttpP ...
- sqlserver工作日常使用sql--持续完善中
select STUFF('232',1,1,'')结果为32,从第一个字符开始去掉一个字符,及去掉 select CONCAT('-','asd')结果为-asd,连接两个字符串 select co ...
- 重新想象 Windows 8.1 Store Apps (88) - 通信的新特性: 新的 HttpClient
[源码下载] 重新想象 Windows 8.1 Store Apps (88) - 通信的新特性: 新的 HttpClient 作者:webabcd 介绍重新想象 Windows 8.1 Store ...
- MySQL Cluster配置概述
一. MySQL Cluster概述 MySQL Cluster 是一种技术,该技术允许在无共享的系统中部署“内存中”数据库的 Cluster .通过无共享体系结构,系统能够使用廉价的硬件,而 ...
- require
/* require.js框架 RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. ...
- 经典实用jQuery soChange幻灯片实例演示
soChange一款多很经典的幻灯片的jQuery插件. 实例预览 引入文件 <link rel="stylesheet" type="text/css" ...
- Git的安装和使用记录
Git是目前世界上最先进的分布式版本控制系统(没有之一),只用过集中式版本控制工具的我,今天也要开始学习啦.廖雪峰的git教程我觉得很详细了,这里记录一下步骤以及我终于学会用Markdown了,真的是 ...
- 最全的前端开发面试题及答案(js,css等等)
点击链接 https://github.com/HerbertKarajan/Fe-Interview-questions 我会不断的更新...... 若想自己留着,可以fork一下. 如果觉得不错, ...
- <SharePoint 2013 用户界面设计与品牌化>学习系列之---基础
什么是SharePoint界面与品牌化设计 这一章主要介绍了: 为什么要品牌化SharePoint 介绍一些内部和互联网的SharePoint网站 简单 中等 复杂的三种品牌化方式 简单难度: 普通用 ...
- C++引用笔记
1.什么是引用: 百度百科里的解释:引用就是某一变量(目标)的一个别名,对引用的操作与对变量直接操作完全一样.用&符号表示 举例: using namespace std; int _tmai ...