hadoop-pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hc busy (JIRA)" <j...@apache.org>
Subject [jira] Commented: (PIG-1303) unable to set outgoing format for org.apache.pig.piggybank.evaluation.util.apachelogparser.DateExtractor
Date Fri, 23 Apr 2010 16:04:53 GMT

    [ https://issues.apache.org/jira/browse/PIG-1303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12860297#action_12860297

hc busy commented on PIG-1303:

But the problem is that inside the EvalFunc constructor, in case of Algebraic classes, it
constructs each of Initial, Intermediate and final which are EvalFunc's that, in my case,
require a parameter to operate correctly.

If I declare the helper class that represent the initial/intermediate/final 

	public class HelperClass extends EvalFunc<Tuple> {
		public HelperClass() {

		public Tuple exec(Tuple input) throws IOException {
			return extreme(fieldIndex, sign, input, reporter);


where the fieldIndex and sign come from the surrounding class (note the class is not static)
then the code crashes. It's not able to construct the HelperClass with this error

could not instantiate 'org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField$HelperClass'
with arguments 'null'
java.lang.RuntimeException: could not instantiate 'org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField$HelperClass'
with arguments 'null'
        at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:498)
        at org.apache.pig.EvalFunc.getReturnTypeFromSpec(EvalFunc.java:136)
        at org.apache.pig.EvalFunc.<init>(EvalFunc.java:123)
        at org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField.<init>(ExtremalTupleByNthField.java:77)
        at org.apache.pig.piggybank.evaluation.TestExtremalTupleByNthField.testMin(Unknown
Caused by: java.lang.InstantiationException: org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField$HelperClass
        at java.lang.Class.newInstance0(Class.java:340)
        at java.lang.Class.newInstance(Class.java:308)
        at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:468)

Basically, I think it's not able to construct because the class can only be constructed from
an instance of ExtremalTupleByNthField.
        ExtremalTupleByNthField etbnf = new ExtremalTupleByNthField("1","max");
        etbnf.new ExtremalTupleByNthField.HelperClass();

So my solution to this problem was to make this class static. But make it so that EvalFunc
can take a vararg that will eventually contain the actual parameters.

the handleChildConstructorParameters method in the EvalFunc will construct a string that represents
the call into the initial/intermediate/final methods but it contains parameters that came
from the ExtremalTupleByNthField.

> unable to set outgoing format for org.apache.pig.piggybank.evaluation.util.apachelogparser.DateExtractor
> --------------------------------------------------------------------------------------------------------
>                 Key: PIG-1303
>                 URL: https://issues.apache.org/jira/browse/PIG-1303
>             Project: Pig
>          Issue Type: Bug
>    Affects Versions: 0.6.0
>         Environment: pig 0.6.0 on a fedora linux machine, jdk 1.6 u11
>            Reporter: Johannes Ru├ček
>            Assignee: Dmitriy V. Ryaboy
>         Attachments: TypeCheckingVisitor.java.diff
> I'm unable to set the format of the outgoing date string in the constructor as it's supposed
to work. 
> The only way i could change the format was to change the default in the java class and
rebuild piggybank.
> Apparently this has something to do with the way pig instantiates DateExtractor, quoting
a replier on the mailing list:
> David Vrensk said:
> I ran into the same problem a couple of weeks ago, and
> played around with the code inserting some print/log statements.  It turns
> out that the arguments are only used in the initial constructor calls, when
> the pig process is starting, but once pig reaches the point where it would
> use the udf, it creates new DateExtractors without passing the arguments.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message