You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Bill Graham <bi...@gmail.com> on 2012/02/03 20:21:12 UTC

Understanding LoadFunc sequence

Hi,

Is there any way to tell in the constructor of a StoreFunc whether it's
being invoked on the client or on the cluster?

Background: on the client I read configs from a config file and set them on
the Configuration object, which I then use on the server. Works great, but
I want to throw an exception if the config isn't found on the client only.

thanks,
Bill

Re: Understanding LoadFunc sequence

Posted by Stan Rosenberg <sr...@proclivitysystems.com>.
Hi Bill,

I've used the following in my UDFs:

public static boolean isBackend(JobContext ctx) {
		// HACK borrowed from HCatLoader: this property should only be set
on the backend
		return ctx.getConfiguration().get("mapred.task.id", "").length() > 0;
    }

I recall seeing other hacks to accomplish the same task; the above
seems to work for now.

stan

On Fri, Feb 3, 2012 at 2:21 PM, Bill Graham <bi...@gmail.com> wrote:
> Hi,
>
> Is there any way to tell in the constructor of a StoreFunc whether it's
> being invoked on the client or on the cluster?
>
> Background: on the client I read configs from a config file and set them on
> the Configuration object, which I then use on the server. Works great, but
> I want to throw an exception if the config isn't found on the client only.
>
> thanks,
> Bill