You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by 李运田 <cu...@163.com> on 2015/06/22 10:20:14 UTC

How I can get the last tuple of a bag

I have data like :
(lucy,{(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45)})
(lili,{(12,lili,23),(12,lili,23),(12,lili,23),(12,lili,34),(12,lili,23),(12,lili,89),(12,lili,23),(12,lili,23),(12,lili,23),(12,lili,34),(12,lili,23),(12,lili,89),(12,lili,23),(12,lili,23)})
(limaomao,{(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56)})
its metadata is: t2: {group: chararray,t1: {(a: int,b: chararray,c: int)}}
I can get first tuple of t1 using limit or FirstTupleFromBag.html .But, How I can get every last tuple of  t1.
thanks

Re: How I can get the last tuple of a bag

Posted by Arvind S <ar...@gmail.com>.
you can try the "ReverseEnumerate" package from datafu on the inner bag and
then filter for 0th element.
http://datafu.incubator.apache.org/docs/datafu/1.2.0/datafu/pig/bags/ReverseEnumerate.html



*Cheers !!*
Arvind

On Mon, Jun 22, 2015 at 1:50 PM, 李运田 <cu...@163.com> wrote:

> I have data like :
>
> (lucy,{(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45)})
>
> (lili,{(12,lili,23),(12,lili,23),(12,lili,23),(12,lili,34),(12,lili,23),(12,lili,89),(12,lili,23),(12,lili,23),(12,lili,23),(12,lili,34),(12,lili,23),(12,lili,89),(12,lili,23),(12,lili,23)})
>
> (limaomao,{(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56)})
> its metadata is: t2: {group: chararray,t1: {(a: int,b: chararray,c: int)}}
> I can get first tuple of t1 using limit or FirstTupleFromBag.html .But,
> How I can get every last tuple of  t1.
> thanks
>

Re: How I can get the last tuple of a bag

Posted by Arvind S <ar...@gmail.com>.
you can try the "ReverseEnumerate" package from datafu on the inner bag and
then filter for 0th element.
http://datafu.incubator.apache.org/docs/datafu/1.2.0/datafu/pig/bags/ReverseEnumerate.html



*Cheers !!*
Arvind

On Mon, Jun 22, 2015 at 1:50 PM, 李运田 <cu...@163.com> wrote:

> I have data like :
>
> (lucy,{(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45),(34,,45)})
>
> (lili,{(12,lili,23),(12,lili,23),(12,lili,23),(12,lili,34),(12,lili,23),(12,lili,89),(12,lili,23),(12,lili,23),(12,lili,23),(12,lili,34),(12,lili,23),(12,lili,89),(12,lili,23),(12,lili,23)})
>
> (limaomao,{(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56),(,limaomao,56)})
> its metadata is: t2: {group: chararray,t1: {(a: int,b: chararray,c: int)}}
> I can get first tuple of t1 using limit or FirstTupleFromBag.html .But,
> How I can get every last tuple of  t1.
> thanks
>