You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "robin zhang tao (Created) (JIRA)" <ji...@apache.org> on 2011/11/16 09:34:51 UTC

[jira] [Created] (PIG-2377) EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final

EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final
------------------------------------------------------------------------------------

                 Key: PIG-2377
                 URL: https://issues.apache.org/jira/browse/PIG-2377
             Project: Pig
          Issue Type: Bug
          Components: impl
    Affects Versions: 0.9.1
            Reporter: robin zhang tao


When EvalFunc check the return type equals with ReturnType of Initial/Intermed/Final, it uses the "==" operator.
But it should not use "==", but "equals()".

I have built one UDF, its return type is "Map<String, Long>", and also the Final class returns "Map<String, Long>".

public class MapLongSum extends EvalFunc<Map<String, Long>> implements Algebraic,
		Accumulator<Map<String, Long>> {
...
...
   static public class Final extends EvalFunc<Map<String, Long>> {
    ...
   }
}

But Pig always reports error: 
 Caused by: java.lang.RuntimeException: Final function of com.duowan.yy.etl.log.eval.MapIntSum is not of the expected type.
        at org.apache.pig.EvalFunc.<init>(EvalFunc.java:146)
        at com.duowan.yy.etl.log.eval.MapIntSum.<init>(MapIntSum.java:40)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:474)
        ... 31 more


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (PIG-2377) EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final

Posted by "robin zhang tao (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-2377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

robin zhang tao updated PIG-2377:
---------------------------------

    Status: Open  (was: Patch Available)
    
> EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final
> ------------------------------------------------------------------------------------
>
>                 Key: PIG-2377
>                 URL: https://issues.apache.org/jira/browse/PIG-2377
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.9.1
>            Reporter: robin zhang tao
>         Attachments: EvalFunc_equals.patch
>
>
> When EvalFunc check the return type equals with ReturnType of Initial/Intermed/Final, it uses the "==" operator.
> But it should not use "==", but "equals()".
> I have built one UDF, its return type is "Map<String, Long>", and also the Final class returns "Map<String, Long>".
> public class MapLongSum extends EvalFunc<Map<String, Long>> implements Algebraic,
> 		Accumulator<Map<String, Long>> {
> ...
> ...
>    static public class Final extends EvalFunc<Map<String, Long>> {
>     ...
>    }
> }
> But Pig always reports error: 
>  Caused by: java.lang.RuntimeException: Final function of com.duowan.yy.etl.log.eval.MapIntSum is not of the expected type.
>         at org.apache.pig.EvalFunc.<init>(EvalFunc.java:146)
>         at com.duowan.yy.etl.log.eval.MapIntSum.<init>(MapIntSum.java:40)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at java.lang.Class.newInstance0(Class.java:355)
>         at java.lang.Class.newInstance(Class.java:308)
>         at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:474)
>         ... 31 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (PIG-2377) EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final

Posted by "robin zhang tao (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-2377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

robin zhang tao updated PIG-2377:
---------------------------------

    Labels: patch  (was: )
    Status: Patch Available  (was: Open)

--- src/org/apache/pig/EvalFunc.java.orig	2011-09-30 06:56:00.000000000 +0800
+++ src/org/apache/pig/EvalFunc.java	2011-11-16 15:17:55.762476800 +0800
@@ -138,11 +138,11 @@
             Algebraic a = (Algebraic)this;
             
             errMsg = "function of " + getClass().getName() + " is not of the expected type.";
-            if (getReturnTypeFromSpec(new FuncSpec(a.getInitial())) != Tuple.class)
+            if (!getReturnTypeFromSpec(new FuncSpec(a.getInitial())).equals(Tuple.class))
                 throw new RuntimeException("Initial " + errMsg);
-            if (getReturnTypeFromSpec(new FuncSpec(a.getIntermed())) != Tuple.class)
+            if (!getReturnTypeFromSpec(new FuncSpec(a.getIntermed())).equals(Tuple.class))
                     throw new RuntimeException("Intermediate " + errMsg);
-            if (getReturnTypeFromSpec(new FuncSpec(a.getFinal())) != returnType)
+            if (!getReturnTypeFromSpec(new FuncSpec(a.getFinal())).equals(returnType))
                     throw new RuntimeException("Final " + errMsg);
         }
         

                
> EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final
> ------------------------------------------------------------------------------------
>
>                 Key: PIG-2377
>                 URL: https://issues.apache.org/jira/browse/PIG-2377
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.9.1
>            Reporter: robin zhang tao
>              Labels: patch
>
> When EvalFunc check the return type equals with ReturnType of Initial/Intermed/Final, it uses the "==" operator.
> But it should not use "==", but "equals()".
> I have built one UDF, its return type is "Map<String, Long>", and also the Final class returns "Map<String, Long>".
> public class MapLongSum extends EvalFunc<Map<String, Long>> implements Algebraic,
> 		Accumulator<Map<String, Long>> {
> ...
> ...
>    static public class Final extends EvalFunc<Map<String, Long>> {
>     ...
>    }
> }
> But Pig always reports error: 
>  Caused by: java.lang.RuntimeException: Final function of com.duowan.yy.etl.log.eval.MapIntSum is not of the expected type.
>         at org.apache.pig.EvalFunc.<init>(EvalFunc.java:146)
>         at com.duowan.yy.etl.log.eval.MapIntSum.<init>(MapIntSum.java:40)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at java.lang.Class.newInstance0(Class.java:355)
>         at java.lang.Class.newInstance(Class.java:308)
>         at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:474)
>         ... 31 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (PIG-2377) EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final

Posted by "robin zhang tao (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-2377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

robin zhang tao updated PIG-2377:
---------------------------------

    Attachment: EvalFunc_equals.patch

patch for EvalFunc check return type equals
                
> EvalFunc should use equals() to check equal for ReturnType of Initial/Intermed/Final
> ------------------------------------------------------------------------------------
>
>                 Key: PIG-2377
>                 URL: https://issues.apache.org/jira/browse/PIG-2377
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.9.1
>            Reporter: robin zhang tao
>         Attachments: EvalFunc_equals.patch
>
>
> When EvalFunc check the return type equals with ReturnType of Initial/Intermed/Final, it uses the "==" operator.
> But it should not use "==", but "equals()".
> I have built one UDF, its return type is "Map<String, Long>", and also the Final class returns "Map<String, Long>".
> public class MapLongSum extends EvalFunc<Map<String, Long>> implements Algebraic,
> 		Accumulator<Map<String, Long>> {
> ...
> ...
>    static public class Final extends EvalFunc<Map<String, Long>> {
>     ...
>    }
> }
> But Pig always reports error: 
>  Caused by: java.lang.RuntimeException: Final function of com.duowan.yy.etl.log.eval.MapIntSum is not of the expected type.
>         at org.apache.pig.EvalFunc.<init>(EvalFunc.java:146)
>         at com.duowan.yy.etl.log.eval.MapIntSum.<init>(MapIntSum.java:40)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at java.lang.Class.newInstance0(Class.java:355)
>         at java.lang.Class.newInstance(Class.java:308)
>         at org.apache.pig.impl.PigContext.instantiateFuncFromSpec(PigContext.java:474)
>         ... 31 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira