Hi Doug,
                  That is where i took my code initially, not able to
notice anything different from there. I know there is something wrong with
the key in key out in my code, but not able to figure out.

I have given below what i am using, Do you see anything wrong in there?

DailySumMapper extends TableMapper<Text, Text>
>>     KEYOUT = Text
>>     VALUEOUT = Text
>>
>>  DailySumReducer extends TableReducer<Text, Text,
>>ImmutableBytesWritable>
>>
>>     KEYIN = Text
>>     VALUEIN = Text
>>     KEYOUT = ImmutableBytesWritable
>>     VALUEOUT = must be always Put or Delete when we extend TableReducer,
>> So we are not specifying that.
>>
>> Code
>>  public static class DailySumReducer extends TableReducer<Text, Text,
>> ImmutableBytesWritable> {
>>
>>         private int count = 0;
>>         protected void reduce(Text key, Iterable<Text>
>> values,Reducer.Context context) throws IOException,
>>InterruptedException{
>>
>>             long inbound = 0l;
>>             long outbound = 0l;
>>             for (Text val : values) {
>>                 String text = val.toString();
>>                 int index = text.indexOf("-");
>>                 String in = text.substring(0,index);
>>                 String out = text.substring(index+1,text.
length());
>>                 inbound = inbound + Long.parseLong(in);
>>                 outbound = outbound + Long.parseLong(out);
>>             }
>>             ByteBuffer data = ByteBuffer.wrap(new byte[16]);
>>             data.putLong(inbound);
>>             data.putLong(outbound);
>>             Put put = new Put(Bytes.toBytes(key.toString()+20120804));
>>             put.add(Bytes.toBytes("t"),
>>Bytes.toBytes("s"),data.array());
>>             context.setStatus("Emitting Put " + count++);
>>             ImmutableBytesWritable ibw = new
>> ImmutableBytesWritable(Bytes.toBytes(key.toString()));
>>             context.write(ibw,put);
>>
>>         }
>>     }



On Wed, Sep 12, 2012 at 11:05 AM, Doug Meil
<[email protected]>wrote:

>
> Did you compare your example to this...
>
> http://hbase.apache.org/book.html#mapreduce.example
> 7.2.2. HBase MapReduce Read/Write Example
>
>
> ?
>
>
>
>
> On 9/12/12 1:02 PM, "Jothikumar Ekanath" <[email protected]> wrote:
>
> >Any help on this one please.
> >
> >On Tue, Sep 11, 2012 at 11:19 AM, Jothikumar Ekanath
> ><[email protected]>wrote:
> >
> >> Hi Stack,
> >>                 Thanks for the reply. I looked at the code and i am
> >>having
> >> a very basic confusion on how to use it correctly.  The code i wrote
> >> earlier has the following input and output types and i want it that way
> >>
> >> After looking at the sources and examples, i modified my reducer (given
> >> below), the mapper and job configuration are still the same. Still i see
> >> the same error. Am i doing something wrong?
> >>
> >>
> >>  DailySumMapper extends TableMapper<Text, Text>
> >>     KEYOUT = Text
> >>     VALUEOUT = Text
> >>
> >>  DailySumReducer extends TableReducer<Text, Text,
> >>ImmutableBytesWritable>
> >>
> >>     KEYIN = Text
> >>     VALUEIN = Text
> >>     KEYOUT = ImmutableBytesWritable
> >>     VALUEOUT = must be always Put or Delete when we extend TableReducer,
> >> So we are not specifying that.
> >>
> >> Code
> >>  public static class DailySumReducer extends TableReducer<Text, Text,
> >> ImmutableBytesWritable> {
> >>
> >>         private int count = 0;
> >>         protected void reduce(Text key, Iterable<Text>
> >> values,Reducer.Context context) throws IOException,
> >>InterruptedException{
> >>
> >>             long inbound = 0l;
> >>             long outbound = 0l;
> >>             for (Text val : values) {
> >>                 String text = val.toString();
> >>                 int index = text.indexOf("-");
> >>                 String in = text.substring(0,index);
> >>                 String out = text.substring(index+1,text.length());
> >>                 inbound = inbound + Long.parseLong(in);
> >>                 outbound = outbound + Long.parseLong(out);
> >>             }
> >>             ByteBuffer data = ByteBuffer.wrap(new byte[16]);
> >>             data.putLong(inbound);
> >>             data.putLong(outbound);
> >>             Put put = new Put(Bytes.toBytes(key.toString()+20120804));
> >>             put.add(Bytes.toBytes("t"),
> >>Bytes.toBytes("s"),data.array());
> >>             context.setStatus("Emitting Put " + count++);
> >>             ImmutableBytesWritable ibw = new
> >> ImmutableBytesWritable(Bytes.toBytes(key.toString()));
> >>             context.write(ibw,put);
> >>
> >>         }
> >>     }
> >>
> >> On Tue, Sep 11, 2012 at 10:38 AM, Stack <[email protected]> wrote:
> >>
> >>> On Mon, Sep 10, 2012 at 7:06 PM, Jothikumar Ekanath
> >>><[email protected]>
> >>> wrote:
> >>> > Hi,
> >>> >        Getting this error while using hbase as a sink.
> >>> >
> >>> >
> >>> > Error
> >>> > java.io.IOException: Pass a Delete or a Put
> >>>
> >>> Would suggest you study the mapreduce jobs that ship with hbase both
> >>> in main and under test.
> >>>
> >>> Looking at your program, you are all Text.  The above complaint is
> >>> about wanting a Put or Delete.  Can you change what you produce so
> >>> Put/Delete rather than Text?
> >>>
> >>> St.Ack
> >>>
> >>
> >>
>
>
>

Reply via email to