日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Pig 知识盲点

發布時間:2024/1/17 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Pig 知识盲点 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. Word Count 例子

inputfile ? = ?load 'file' ?as (line);

內容:

{line: bytearray}

(Look at the stars, )
(Look how they shine for you, )
(And everything you do, )
(Yeah they were all yellow,)


wordsLine = ?foreach inputfile ??generate flatten(TOKENIZE(line)) ?aseachWord;

內容:

?{eachWord: chararray}

(Look)
(at)
(the)
(stars)
(Look)
(how)
(they)
(shine)
(for)
(you)
(And)
(everything)
(you)
(do)
(Yeah)
(they)
(were)
(all)
(yellow)


groupedWords = group?wordsLine?by eachWord;

內容:

{group: chararray,wordsLine: {(eachWord: chararray)}}

(at,{(at)})
(do,{(do)})
(And,{(And)})
(all,{(all)})
(for,{(for)})
(how,{(how)})
(the,{(the)})
(you,{(you),(you)})
(Look,{(Look),(Look)})

(Yeah,{(Yeah)})
(they,{(they),(they)})
(were,{(were)})
(shine,{(shine)})
(stars,{(stars)})
(yellow,{(yellow)})
(everything,{(everything)})


wordcount = foreach ?groupedWords ?generate ?group, COUNT(wordsLine) as cnt

?{group: chararray, cnt:long}

(at,1)
(do,1)
(And,1)
(all,1)
(for,1)
(how,1)
(the,1)
(you,2)
(Look,2)
(Yeah,1)
(they,2)
(were,1)
(shine,1)
(stars,1)
(yellow,1)
(everything,1)




2.Pig 返回碼

0: 成功;1:失敗,可重試;2:失敗;3:部分失敗......其余是各種異常。


3. 復雜數據類型(很少用)

map: ? ?

tuple: 定長有序 ? ?

bag: 無序 ??


4. NULL值

null ?對任何運算符都抵消:

x+null = null

null==1 ? 1: 0 , ?返回值為null?


5.加載和存儲?

加載函數:

PigStoreage(',') :HDFS路徑

HBaseStoreage():HBase表

TextLoader:?HDFS路徑, 每行作為一個tuple


存儲函數

PigStoreage(',') :HDFS路徑

HBaseStoreage():HBase表

TextLoader:?HDFS路徑, 每行作為一個tuple


6.大小寫敏感: 關鍵字不敏感: load == LOAD? 變量敏感:tablea != tableA 自定義函數敏感: count != COUNT

7.Parallel

可觸發reduce的操作:group、order、distinct、join、cogroup、cross

后面可使用parallel 指定 并行數目


8. 注冊UDF

使用命令register,或者屬性 -Dudf.import.list, 或-Dpig.additional.jars


9. Java靜態函數

實際是使用反射來運行


10. flattern

操作bag,一行變多行


11. ?replicated Join

map side join


12. skew join

先抽樣,確定鍵的分布,重寫partitioner,從而均衡各個reducer的負載


13. merge join

已經排好序,比默認的高效


14. cogroup

對多個輸入進行group,如 : C = ?cogroup A by id, B by id.

相當于join的前一半


15. stream

執行perl、python等腳本


16. ?直接運行mapreduce

使用mapreduce命令執行


17. ?有向無環圖 DAG


18. 分割器 Partitioner

可注冊自定義jar包


19. 宏

使用define關鍵字


20. 嵌套Pig 腳本

使用import關鍵字


21. 執行計劃 exlain

用于調試


22. illustrate

用于調試


23. Pig 統計信息

在日志或者終端輸出


24. PigUnit

集成到JUnit


25. ?與 Python 交互


26. 評估函數

求值函數,繼承org.apache.pig.EvalFunc<V>, 實現 ecec(Tuple input)

也可以用Python書寫


27.?過濾函數

繼承org.apache.pig.FilterFunc


28. 加載函數


29. 存儲函數


30. Piggybank

內置常用聚合函數、數學函數、字符串處理函數。

特別的,有正則表達式匹配函數:REGEX_EXTRACT、REGEX_EXTRACT_ALL

統計函數:相關系數COR、協方差COV等等。








轉載于:https://www.cnblogs.com/leeeee/p/7276132.html

總結

以上是生活随笔為你收集整理的Pig 知识盲点的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。