You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Stan Rosenberg <sr...@proclivitysystems.com> on 2011/11/08 04:01:11 UTC
get schema in StorageFunc
Hi All,
I'd like to get the schema of a relation that is used in conjunction
with my custom StorageFunc. I found 'checkSchema' to be useful for
this case, however, it seems to work only in local mode. When run in
distributed mode, 'checkSchema' is not invoked in mappers.
Is there some other means to retrieve the schema?
Thanks in advance,
stan
Re: get schema in StorageFunc
Posted by Dmitriy Ryaboy <dv...@gmail.com>.
Stan, you have to serialize the schema into the job conf using the
signature passed to you in setUDFContextSignature.
your code will look something like this:
@Override
public void checkSchema(ResourceSchema s) throws IOException {
this.schema = s;
getUDFProperties().setProperty(contextSignature + "_schema"
, ObjectSerializer.serialize(schema));
}
@Override
public void setUDFContextSignature(String signature) {
this.contextSignature = signature;
}
@Override
public void setStoreLocation(String location, Job job) throws IOException {
String serializedSchema = getUDFProperties().getProperty(
contextSignature + "_schema");
if (serializedSchema!= null) {
this.schema = (ResourceSchema)
ObjectSerializer.deserialize(serializedSchema);
}
}
On Mon, Nov 7, 2011 at 7:01 PM, Stan Rosenberg <
srosenberg@proclivitysystems.com> wrote:
> Hi All,
>
> I'd like to get the schema of a relation that is used in conjunction
> with my custom StorageFunc. I found 'checkSchema' to be useful for
> this case, however, it seems to work only in local mode. When run in
> distributed mode, 'checkSchema' is not invoked in mappers.
> Is there some other means to retrieve the schema?
>
> Thanks in advance,
>
> stan
>