[
https://issues.apache.org/jira/browse/PIG-2317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13127879#comment-13127879
]
Jacob Perkins commented on PIG-2317:
------------------------------------
I like the idea of a gem, especially from the added utilities standpoint. The
one thing I'd like to avoid with a gem though is creating a dsl and instead
keeping the syntax as obvious as possible. Extending a class feels right:
{code:title=concat.rb}
require 'pigudf'
class Concat < PigUdf
def output_schema
"str:chararray"
end
def eval str
str + str
end
end
{code}
but leads to lots of extra lines of code when all I really wanted to do was
concat two strings...
I would rather see something like this:
{code:title=concat.rb}
require 'pigudf'
Concat = PigUdf.new("str:chararray") do |str|
str + str
end
{code}
Which is a dead simple class in ruby:
{code:title=pigudf.rb}
class PigUdf
def self.new output_schema, &blk
Class.new do
@@output_schema = output_schema
@@blk = blk
def output_schema
@@output_schema
end
def eval *args
@@blk.call(*args)
end
end
end
end
{code}
I also suspect that, with everything wrapped in a class, the java side of
things becomes even simpler. Thoughts?
> 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_real.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