Does PigClass have a constructor that takes a single String? Can you share the code for your UDF?
Alan. On Nov 28, 2011, at 12:26 AM, Anil Barfa wrote: > Thanks Prashant, > I am using 'Apache Pig version 0.8.0'. > package name is correct. > It work correct if i remove constructor (i.e if remove constructor and > remove '--define' from pig script.) > > > > On Mon, Nov 28, 2011 at 1:41 PM, Prashant Kommireddi > <[email protected]>wrote: > >> What version of Pig are you using? Can you make sure the package name/path >> "myjar.PigClass" is correct. >> >> On Sun, Nov 27, 2011 at 11:56 PM, Anil Barfa <[email protected]> wrote: >> >>> Hi >>> I am using java UDF with pig. I want pass file name to UDF. I have done >> it >>> as follows but it is not working. >>> >>> PIg script >>> >>> REGISTER myjar.jar; >>> DEFINE myfun myjar.PigClass('/home/myfile.txt'); >>> >>> --load input data >>> InputValue = LOAD '$input' AS (val1,val2,val3); >>> >>> InputWithMeta = FOREACH InputValue GENERATE myfun(val1,val2,val3); >>> >>> >>> Java code PigClass.java >>> >>> class PigClass extends EvalFunc<Tuple> >>> { >>> public PigClass(String strPath) >>> { >>> } >>> public Tuple exec(Tuple input ) throws IOException { >>> } >>> }; >>> >>> I am getting following Error. >>> >>> *<file MyScript.pig, line 7, column 45> Failed to generate logical plan. >>> Nested exception: java.lang.RuntimeException: could not instantiate ' >>> myjar.PigClass**' with arguments '[/home/myfile.txt]'* >>> >>> >>> Thanks and Regards >>> Anil Barfa >>> >>
