crunch-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venkatesh kavuluri <venkatesh.kowl...@gmail.com>
Subject Re: call DoFn#increment from helper class
Date Wed, 18 Feb 2015 21:46:49 GMT
Thanks Josh. I followed the former approach
involving TaskInputOutputContext and I am able to implement the job
counters.

On Thu, Feb 12, 2015 at 4:19 PM, Josh Wills <jwills@cloudera.com> wrote:

> 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