现在的位置: 首页 > 综合 > 正文

【pig】挑选合适的数据类型(待翻译)

2013年07月11日 ⁄ 综合 ⁄ 共 920字 ⁄ 字号 评论关闭

As discussed elsewhere, Pig can run with or without data type information. In cases
where the load function you are using creates data that is already typed, there is little
you need to do to optimize the performance. However, if you are using the default
PigStorage load function that reads tab-delimited files, then whether you use types will
affect your performance.
On the one hand, converting fields from bytearray to the appropriate type has a cost.
So, if you do not need type information, you should not declare it. For example, if you
are just counting records, you can omit the type declaration without affecting the out-
come of your script.
On the other hand, if you are doing integer calculations, types can help your script
perform better. When Pig is asked to do a numeric calculation on a bytearray, it treats
that bytearray as a double because this is the safest assumption. But floating-point
arithmetic is much slower than integer arithmetic on most machines. For example, if
you are doing a SUM over integer values, you will get better performance by declaring
them to be of type integer.

抱歉!评论已关闭.