總網頁瀏覽量

2012年10月30日 星期二

三個臭皮匠

浴室(廁所)真是一個發人省思的好地方。

剛剛洗澡時思緒突然天馬行空起來,

我在想line之類的即時通訊軟體如何處理巨量的使用者訊息呢,

(最近在做performance testing)

接著又想到當初LINE大打廣告,也不見任何收費機制,

有些評論便指出此舉是為了搶佔市場,

待市佔率成熟時不管推出什麼商業模式使用者都較容易買單。

現下,

LINE也不出所料推的出了插圖收費機制,

我又想了,

像我這樣窮酸摳門的人,這一輩子肯定半毛都不會貢獻給LINE吧!

但又為什麼這種80%利潤來自20%的商業模式能夠運行不衰呢

歸根究底,

個體無法代表全體阿。

所以說,

不管是認為一個IDEA可不可行,

一個程式邏輯漂不漂亮,

還是,一個商業模式work不work,

都不是單單一個人就能決定的。

無怪乎討論、分享的動作是如此重要,

即便是被認為理所當然的事,

都有可能從別人的腦袋中迸出意想不到的思考模式。

而透過如此不斷的增廣見聞,

才能打開被自己侷限住的視界。

2012年10月26日 星期五

Be careful using COUNT in pig


I’m running some pig script to count the number of rows.
And found that the COUNT function ignore rows in bag which has null in first field.
I change the field order and take experiments bellow
 
--------- source file ----------
A       E       G
        F       H
B       F       I
 
 
[Experiment#1]
--------- pig ----------
A =load '/user/myspn/exp' using PigStorage() as (X:chararray, Y:chararray, Z:chararray);
B = group A by (X,Y);
C = foreach B generate group.$0, group.$1, A, COUNT(A);
dump C;
--------- result ----------
(,F,{(,F,H)},0)
(A,E,{(A,E,G)},1)
(B,F,{(B,F,I)},1)
 
 
[Experiment#2]
--------- pig ----------
A =load '/user/myspn/exp' using PigStorage() as (X:chararray, Y:chararray, Z:chararray);
D = foreach A generate Y, X, Z;
B = group D by (Y,X);
C = foreach B generate group.$0, group.$1, D, COUNT(D);
dump C;
--------- result ----------
(F,,{(F,,H)},1)
(E,A,{(E,A,G)},1)
(F,B,{(F,B,I)},1)
 
 
In experiment#1 we see that the group function still works fine but COUNTs nothing.
So the conclusion is making sure that the first field of rows to be count is not null.