[ 
https://issues.apache.org/jira/browse/PIG-2547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bill Graham updated PIG-2547:
-----------------------------

    Attachment: PIG_2547.1.patch

Here's a first pass at a patch. It includes a number of new files:

{noformat}
src/org/apache/pig/ExceptionalFunction.java
src/org/apache/pig/Function.java
src/org/apache/pig/FunctionWrapperEvalFunc.java
src/org/apache/pig/PrimitiveEvalFunc.java
src/org/apache/pig/TypedOutputEvalFunc.java
test/org/apache/pig/TestFunctionWrapperEvalFunc.java
test/org/apache/pig/TestPrimitiveEvalFunc.java
test/org/apache/pig/TestTypedOutputEvalFunc.java
{noformat}

The new Pig {{Function}} interface was added as a common subinterface to 
Googles {{Function}} and a new Pig {{ExceptionalFunction}}.

I went through some pains to support all three interfaces in 
{{FunctionWrapperEvalFunc}}. (Dmitriy, this is different than our impl, which 
doesn't include support for Google's {{Function}}.)

Please take a look and let me know what you think.

                
> Easier UDFs: Convenient EvalFunc super-classes
> ----------------------------------------------
>
>                 Key: PIG-2547
>                 URL: https://issues.apache.org/jira/browse/PIG-2547
>             Project: Pig
>          Issue Type: New Feature
>            Reporter: Bill Graham
>            Assignee: Bill Graham
>         Attachments: PIG_2547.1.patch
>
>
> We've got a few abstract extensions of EvalFunc that make life easier. If 
> people are interested we can push said classes into Pig.
> There are 3 classes, each extending the next. Class naming is all TBD.
> * {{TypedOutputEvalFunc<OUT>}} - Implements {{public Schema 
> outputSchema(Schema input)}} based on the generic type of the subclass. 
> Provides common helper validation functions which increment counters for good 
> and bad Tuple data passed. Useful where the input to be worked on is a tuple 
> of size N or greater. 
> * {{PrimitiveEvalFunc<IN, OUT>}} - Same as above with helper validation 
> allowing the ability it subclass and just implement {{public OUT exec(IN 
> input)}}, where IN and OUT are primitives. Useful when the input is a single 
> primitive in position 0 of a tuple. 
> * {{FunctionWrapperEvalFunc}} - Wraps a Guava Function implementation 
> (http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Function.html)
>  and allows UDFs to be used in Pig scripts like so, where {{MyFunction}} is a 
> class that implements {{Function}}:
> {noformat}
> DEFINE myUdf org.apache.pig.FunctionWrapperEvalFunc('MyFunction')
> {noformat}
>  

--
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

        

Reply via email to