pig中使用的一些实例语法,pig使用实例语法


1:加载名用正则表达式:
LOAD '/user/wizad/data/wizad/raw/2014-0{6,7-0,7-1,7-2,7-3,8}*/3_1/adwords*'

2:filter的几种简单用法:

按值过滤

FILTER clickDate_all BY log_type=='2';
FILTER mapping_table BY mapping_ad_network_id=='3' AND mapping_type=='5';
test =FILTER allRow BY (ad_id=='14997' OR ad_id=='14998' OR ad_id=='14999') AND log_type==2;
test=FILTER allRow BY (INDEXOF(ad_id,'14997')==0 OR INDEXOF(ad_id,'14998')==0 OR INDEXOF(ad_id,'14999')==0) AND log_type==2;

配合size函数

FILTER count_imei BY (SIZE(cimei)>14 AND SIZE(cimei)<17);


正则表达式

FILTER cimei2 BY NOT cimei MATCHES '^[0-9]*$';
FILTER cmac2 BY cmac MATCHES '/[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}/';


3:排序

ORDER province_count BY $2 DESC;


4:CONCAT函数的使用。可用于生成独立的一列,如count了的一个数,前面加一列名称
FOREACH origin_cleaned_data GENERATE CONCAT('<-_','->') AS cou,guid,log_type;
read_social_14 =FOREACH metadata_social_14 GENERATE CONCAT('14','=='),guid_social;
all_id =FOREACH allRow GENERATE id,CONCAT('_','-') as cc;

5:值替换:过滤空值,改成取值为unknown。
origin_historical = FOREACH origin_cleaned_data GENERATE wizad_ad_id,guid,log_type,
((province_region_id == '') ? 'unknown' : province_region_id)

6:切分成不同子集,按值:
 SPLIT geelyTuiGuang INTO android IF os_id==1,ios IF os_id==2;
 SPLIT ios INTO ios6 IF (INDEXOF(os_version,'7')!=0),ios7 IF INDEXOF(os_version,'7')==0;

7:replace函数替换值
 FOREACH ios6 GENERATE imei,mac_address as cmac,REPLACE(idfa,'null','');

8:
 en_guid =STREAM duimei THROUGH `awk -F"," '{if($3 == "null") print $1","$2","; else print $0}'`;



语法在实例中的用法

名词所有格用来表示两个人或事物之间的相属关系,相当于中文的“某某人的什么什么人或东西”。这种形式只有名词才能用,所以叫名词的所有格。一般是在名词后加一个’s或者使用of 词组来表示,'s 或 of 可以解释为“……的”。 名词's 和of...都表示“……的”,两者意思差不多。但是,问题是:在英语中什么情况下用's,什么情况下用of...,有一些约定俗成的习惯,这也是英语初学者比较难理解的地方。本文通过大量的实例,简要地概括了's 与 of...的用法及其注意事项。 1. ’s 和' 的用法 使用's 或' 的情况,主要用于有生命的东西。如果名词不是以s字母结尾的话,则加上's;如果名词本身就以s 字母结尾,则只加一个' 即可。例如: Have you read Robert Browning’s poems? 你读过罗伯特·勃郎宁的诗吗? It’s made from mare’s,cow’s or ewe’s milk. 它是用马奶、牛奶或者羊奶制成的。 My teacher is having a rest at the Teachers' Room. 我的老师正在教师休息室休息。 但是,'s 或' 也可用于表示时间、城市、地域、团体、机构等非生命的事物。实际上,英语中除了时间之外,也把城市、地域、团体、机构等当作“拟人”来使用。例如: We accepted the invitation without a moment’s hesitation. 我们一点也没有犹豫就接受了邀请。 New York’s population is much larger than Washington’s,though it is not the capital city. 纽约的人口比华盛顿多得多,虽然它并不是首都城市。 They are holding conferences to discuss the Europe’s future. 他们正召开各种会议来讨论欧洲的前景。 We heartily applauded the delegation’s successful visit. 我们热烈欢呼代表团访问成功。 Professor Smith is teaching at Yale’s Department of Literature. 史密斯教授在耶鲁大学文学系任教。 当然,在某些习惯用语中,尽管是表示无生命的名词,也需要’s的所有格。这是所有格的特殊性,没多少规律可找,只有靠我们平时注意积累了。例如: The driver escaped the death by a hair’s breadth. 那个司机这回真是九死一生。 Now you may sing to your heart’s content. 你现在可以尽情地唱了。 for friendship’s sake(为了友情) at a stone’s throw(一箭之远) at one’s finger’s tip(手头上有) at arm’s length(保持距离) at one’s wits’end(黔驴技穷) 2. of 短语的用法 of 短语,也相当于中文的“……的”。注意:同中文相比,它是反过来说的,如“二班的学生”,英语是 the students of Class Two (学生二班的”。它的用法,相对于有生命的's 或' 来说,of.........余下全文>>
 

教Verilog中模块的调用(实例化)的语法

logic cell不足是因为逻辑单元超过了fpga内部的个数,要选用更大的fpga或者优化代码
 

相关内容