[
https://issues.apache.org/jira/browse/PIG-1678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Ciemiewicz updated PIG-1678:
----------------------------------
Description:
I would like to have a trivial way to bind and invoke Java library functions
from within Pig without creating wrapper functions in Java.
For instance, I need functions out of the Apache Commons Math library
(http://commons.apache.org/math/) such as
BetaDistributionImpl.cumulativeProbability.
http://commons.apache.org/math/apidocs/org/apache/commons/math/distribution/BetaDistributionImpl.html
To use this class, I must first create a new object with a parameterized
constructor -- BetaDistributionImpl(alpha,beta) and then I can invoke a method.
This two stage process of object instantiation and then method invocation is a
bit clumsy, necessitating a wrapper function.
I would like to be able to specify Pig a pig binding of something like the
following which would allow me to easily declare a binding that performs both
steps without the need for a wrapper.
{code}
register commons-math-2.1.jar;
define (new org.apache.commons.math.distribution.BetaDistributionImpl((double)
alpha, (double) beta)).cumulativeProbability((double) x) BetaIncomplete(x,
alpha, beta)
{code}
What is special about BetaDistributionImpl is that I must first construct an
object instance with parameters of alpha and beta, then I need to invoke the
object method cumulativeProbability to compute my function.
This requires about 100 lines of Java code to create a wrapper just to this one
function instance. And there are something like 1000 functions to bind to.
Better yet, if I could just say something like:
{code}
register commons-math-2.1.jar;
import org.apache.commons.math.distribution.BetaDistributionImpl as BetaDist;
B = foreach A as
alpha,
beta,
x,
BetaDist(alpha,beta).cumulativeProbability(x) as prob;
{code}
Ideally I'd be able to register or include a list of all the bindings to the
library without ever having write another Eval func wrapper.
was:
I would like to have a trivial way to bind and invoke Java library functions
from within Pig without creating wrapper functions in Java.
For instance, I need functions out of the Apache Commons Math library
(http://commons.apache.org/math/) such as
BetaDistributionImpl.cumulativeProbability.
http://http://commons.apache.org/math/apidocs/org/apache/commons/math/distribution/BetaDistributionImpl.html
To use this class, I must first create a new object with a parameterized
constructor -- BetaDistributionImpl(alpha,beta) and then I can invoke a method.
This two stage process of object instantiation and then method invocation is a
bit clumsy, necessitating a wrapper function.
I would like to be able to specify Pig a pig binding of something like the
following which would allow me to easily declare a binding that performs both
steps without the need for a wrapper.
{code}
register commons-math-2.1.jar;
define (new org.apache.commons.math.distribution.BetaDistributionImpl((double)
alpha, (double) beta)).cumulativeProbability((double) x) BetaIncomplete(x,
alpha, beta)
{code}
What is special about BetaDistributionImpl is that I must first construct an
object instance with parameters of alpha and beta, then I need to invoke the
object method cumulativeProbability to compute my function.
This requires about 100 lines of Java code to create a wrapper just to this one
function instance. And there are something like 1000 functions to bind to.
Better yet, if I could just say something like:
{code}
register commons-math-2.1.jar;
import org.apache.commons.math.distribution.BetaDistributionImpl as BetaDist;
B = foreach A as
alpha,
beta,
x,
BetaDist(alpha,beta).cumulativeProbability(x) as prob;
{code}
Ideally I'd be able to register or include a list of all the bindings to the
library without ever having write another Eval func wrapper.
> Need a easy way to bind to external Java library functions that require
> object constructors such as Apache Commons Math library
> -------------------------------------------------------------------------------------------------------------------------------
>
> Key: PIG-1678
> URL: https://issues.apache.org/jira/browse/PIG-1678
> Project: Pig
> Issue Type: New Feature
> Reporter: David Ciemiewicz
>
> I would like to have a trivial way to bind and invoke Java library functions
> from within Pig without creating wrapper functions in Java.
> For instance, I need functions out of the Apache Commons Math library
> (http://commons.apache.org/math/) such as
> BetaDistributionImpl.cumulativeProbability.
>
> http://commons.apache.org/math/apidocs/org/apache/commons/math/distribution/BetaDistributionImpl.html
> To use this class, I must first create a new object with a parameterized
> constructor -- BetaDistributionImpl(alpha,beta) and then I can invoke a
> method.
> This two stage process of object instantiation and then method invocation is
> a bit clumsy, necessitating a wrapper function.
> I would like to be able to specify Pig a pig binding of something like the
> following which would allow me to easily declare a binding that performs both
> steps without the need for a wrapper.
> {code}
> register commons-math-2.1.jar;
> define (new
> org.apache.commons.math.distribution.BetaDistributionImpl((double) alpha,
> (double) beta)).cumulativeProbability((double) x) BetaIncomplete(x, alpha,
> beta)
> {code}
> What is special about BetaDistributionImpl is that I must first construct an
> object instance with parameters of alpha and beta, then I need to invoke the
> object method cumulativeProbability to compute my function.
> This requires about 100 lines of Java code to create a wrapper just to this
> one function instance. And there are something like 1000 functions to bind
> to.
> Better yet, if I could just say something like:
> {code}
> register commons-math-2.1.jar;
> import org.apache.commons.math.distribution.BetaDistributionImpl as BetaDist;
> B = foreach A as
> alpha,
> beta,
> x,
> BetaDist(alpha,beta).cumulativeProbability(x) as prob;
> {code}
> Ideally I'd be able to register or include a list of all the bindings to the
> library without ever having write another Eval func wrapper.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.