crunch-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Wills <jwi...@cloudera.com>
Subject Re: call DoFn#increment from helper class
Date Fri, 13 Feb 2015 00:19:08 GMT
You could pass the TaskInputOutputContext to foo and call its Counter
methods directly, something like:

@Override
public void process (S input, Emitter<T> emitter) {
    foo.processAndEmitEvents(bar, emitter, getContext());
}

or you could add a public inc() method to your A class, pass "this" to
processAndEmitEvents, and have that public inc() method call the protected
increment() method.

J


On Thu, Feb 12, 2015 at 4:12 PM, venkatesh kavuluri <
venkatesh.kowluru@gmail.com> wrote:

> Hi All,
>
> I am trying to figure out the best way to call increment method (for
> counters) from a helper class invoked from DoFn#process.
>
> I have something like this.
>
> class A extends DoFn<> {
>
> Foo foo = nee Foo(); // helper class
>
> @Override
> public void process (S input, Emitter<T> emitter) {
>     foo.processAndEmitEvents(bar, emitter);
> }
>
> I want to call DoFn#increment method from Foo#processAndEmitEvents. Is
> there a better way to go about it other than “Foo" extending “A” just to
> get hold of DoFn#increment.
>
> Thanks for the help.
>



-- 
Director of Data Science
Cloudera <http://www.cloudera.com>
Twitter: @josh_wills <http://twitter.com/josh_wills>

Mime
View raw message