incubator-crunch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Friedrich <m...@mafr.de>
Subject Re: Supporting legacy Mapper and Reducer classes in Crunch
Date Wed, 26 Sep 2012 16:14:51 GMT
Hi,

On Tuesday, 2012-09-25, Josh Wills wrote:
[...]
> But this is trickier-- I need to actually subclass Map.Context and
> Reduce.Context for this to work. It's straightforward-- we delegate ~
> everything to the underlying Map.Context or Reduce.Context object
> w/the exception of the write() method, which gets handled by the
> Emitter object. The only catch is that the subclasses need to call the
> parent constructor in their own constructors, and the signatures are
> different in hadoop 1 and 2.

Can we use a dynamic proxy perhaps? The one from the JDK only works
for interfaces, but you could use javassist's ProxyFactory [1] that
can create proxies for classes. The API is pretty simple, delegate
everything except write() using a MethodFilter and add a MethodHandler
for write() that calls your Emitter.

Regards,
  Matthias

[1] http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/html/javassist/util/proxy/ProxyFactory.html

Mime
View raw message