You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Daan Gerits <da...@gmail.com> on 2011/11/09 20:45:58 UTC

UDF Counters

Hello everyone,

Is it possible to update a counter from within an UDF? I know there is some information on updating counters using log messages, but I have never done that before and have no idea if it is working with pig.

Thanks,

Daan.

Re: UDF Counters

Posted by Stan Rosenberg <sr...@proclivitysystems.com>.
On Wed, Nov 9, 2011 at 2:45 PM, Daan Gerits <da...@gmail.com> wrote:
> Hello everyone,
>
> Is it possible to update a counter from within an UDF? I know there is some information on updating counters using log messages, but I have never done that before and have no idea if it is working with pig.
>

This seems to work for me:

                       PigStatusReporter reporter =
PigStatusReporter.getInstance();
			if (reporter != null) {
			   reporter.getCounter("name", "group").increment(1);
			}

Also see http://squarecog.wordpress.com/2010/12/24/incrementing-hadoop-counters-in-apache-pig/