[
https://issues.apache.org/jira/browse/PIG-2317?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jonathan Coveney updated PIG-2317:
----------------------------------
Attachment: jruby_scripting_2.patch
Here is a modified version of the Jruby patch. It builds off of the excellent
work Jacob did, but simplified greatly the function registration and the method
invocation.
There are two supported forms, which can be mix and matched. They generally
mirror the python form.
{code}
outputSchema "word:chararray"
def helloworld
return 'Hello, World'
end
outputSchema "word:chararray,num:long"
def complex word
return [word.to_s,word.length]
end
outputSchemaFunction :squareSchema
def square num
return num**2
end
def squareSchema input
return input
end
{code}
and
{code}
def helloworld
return 'Hello, World'
end
def complex word
return [word.to_s,word.length]
end
def square num
return num**2
end
def squareSchema input
return input
end
outputSchema :helloworld, "word:chararray"
outputSchema :complex, "word:chararray,num:long"
outputSchemaFunction :square, :squareSchema
{code}
There is one key difference, though, which is that this version only registers
functions with an explicit schema. While it does mean that you need a schema
for every function, I think it more cleanly allows for people to write scripts
where there are helper functions.
Please let me know what you think. Oh, I also split out the JavaScript, Python,
and Ruby scripting tests into different files...the ruby and python ones take
long enough and are substantial enough that it is annoying to have to run them
all at once to test a change just to the ruby implementation.
> Ruby/Jruby UDFs
> ---------------
>
> Key: PIG-2317
> URL: https://issues.apache.org/jira/browse/PIG-2317
> Project: Pig
> Issue Type: New Feature
> Reporter: Jacob Perkins
> Assignee: Jacob Perkins
> Priority: Minor
> Fix For: 0.9.2
>
> Attachments: jruby_scripting.patch, jruby_scripting_2.patch
>
>
> It should be possible to write UDFs in Ruby. These UDFs will be registered in
> the same way as python and javascript UDFs.
--
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