You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by sulabh choudhury <su...@gmail.com> on 2011/03/29 17:22:22 UTC

java.lang.IllegalArgumentException in incrementColumnValue and Increment

Hi,

Unable to use the Increment function, can anybody suggest what am I doing
wrong...

I enter data by :-
theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
Bytes.toBytes(10))

Now when I try to increment the value I have tried...
mytable.incrementColumnValue(Bytes.toBytes("row5"),
Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
mytable.incrementColumnValue(Bytes.toBytes("row5"),
Bytes.toBytes("uid"),Bytes.toBytes("1"),1)

also
val inc = new Increment(Bytes.toBytes("row" + 5))
inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
mytable.increment(inc)

In both of the cases, I get an error like
org.apache.hadoop.hbase.client.RetriesExhaustedException:
Exceptions:
java.io.IOException: java.io.IOException:
java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
capacity of the array: 32
at
org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
 at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
at
org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
 at
org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
 at sun.reflec...


I guess I have tried all possible combinations of datatypes....I could not
even find a decent example of incrementColumnValue()

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by sulabh choudhury <su...@gmail.com>.
Yes. I found the same information.

On Tue, Mar 29, 2011 at 12:23 PM, Jesse Hutton <je...@gmail.com>wrote:

> AFAIK, (and maybe some experts can chime in here with some details) there
> is no real way to over write a value in hbase. If you want to control the
> number of versions, you can set the "max versions" property on the column
> family, and that will be enforced whenever a major compaction occurs [1].
>
> Jesse
>
> 1) http://www.outerthought.org/blog/465-ot.html
>
>
> On Tue, Mar 29, 2011 at 12:43 PM, sulabh choudhury <su...@gmail.com>wrote:
>
>> I just realized that using the increment function creates another version,
>> with a new timestamp.
>> Is there a way we can use the previous TS, hence over writing the value ?
>>
>> On Tue, Mar 29, 2011 at 9:38 AM, sulabh choudhury <su...@gmail.com>
>> wrote:
>>
>> > Thanks Jesse. Changing the 10 to 10L made it work.
>> >
>> > On Tue, Mar 29, 2011 at 8:59 AM, Jesse Hutton <jesse.hutton@gmail.com
>> >wrote:
>> >
>> >> Hi,
>> >>
>> >> It looks like the problem is that the initial value you're inserting in
>> >> the column is an int, while HTable#incrementColumnValue() expects a
>> long.
>> >> Instead of:
>> >>
>> >>
>> >>> I enter data by :-
>> >>> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L +
>> t,
>> >>> Bytes.toBytes(10))
>> >>>
>> >>
>> >> try:
>> >> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
>> >> Bytes.toBytes(10L));
>> >>
>> >> Jesse
>> >>
>> >>
>> >>>
>> >>> Now when I try to increment the value I have tried...
>> >>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
>> >>> Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
>> >>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
>> >>> Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>> >>>
>> >>> also
>> >>> val inc = new Increment(Bytes.toBytes("row" + 5))
>> >>> inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>> >>> mytable.increment(inc)
>> >>>
>> >>> In both of the cases, I get an error like
>> >>> org.apache.hadoop.hbase.client.RetriesExhaustedException:
>> >>> Exceptions:
>> >>> java.io.IOException: java.io.IOException:
>> >>> java.lang.IllegalArgumentException: offset (28) + length (8) exceed
>> the
>> >>> capacity of the array: 32
>> >>> at
>> >>>
>> >>>
>> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
>> >>>  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
>> >>> at
>> >>>
>> >>>
>> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
>> >>>  at
>> >>>
>> >>>
>> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
>> >>> at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
>> >>>  at sun.reflec...
>> >>>
>> >>>
>> >>> I guess I have tried all possible combinations of datatypes....I could
>> >>> not
>> >>> even find a decent example of incrementColumnValue()
>> >>>
>> >>
>> >>
>> >
>> >
>> >
>> >
>>
>
>

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by Jesse Hutton <je...@gmail.com>.
AFAIK, (and maybe some experts can chime in here with some details) there is
no real way to over write a value in hbase. If you want to control the
number of versions, you can set the "max versions" property on the column
family, and that will be enforced whenever a major compaction occurs [1].

Jesse

1) http://www.outerthought.org/blog/465-ot.html

On Tue, Mar 29, 2011 at 12:43 PM, sulabh choudhury <su...@gmail.com>wrote:

> I just realized that using the increment function creates another version,
> with a new timestamp.
> Is there a way we can use the previous TS, hence over writing the value ?
>
> On Tue, Mar 29, 2011 at 9:38 AM, sulabh choudhury <su...@gmail.com>
> wrote:
>
> > Thanks Jesse. Changing the 10 to 10L made it work.
> >
> > On Tue, Mar 29, 2011 at 8:59 AM, Jesse Hutton <jesse.hutton@gmail.com
> >wrote:
> >
> >> Hi,
> >>
> >> It looks like the problem is that the initial value you're inserting in
> >> the column is an int, while HTable#incrementColumnValue() expects a
> long.
> >> Instead of:
> >>
> >>
> >>> I enter data by :-
> >>> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
> >>> Bytes.toBytes(10))
> >>>
> >>
> >> try:
> >> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
> >> Bytes.toBytes(10L));
> >>
> >> Jesse
> >>
> >>
> >>>
> >>> Now when I try to increment the value I have tried...
> >>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
> >>> Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
> >>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
> >>> Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
> >>>
> >>> also
> >>> val inc = new Increment(Bytes.toBytes("row" + 5))
> >>> inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
> >>> mytable.increment(inc)
> >>>
> >>> In both of the cases, I get an error like
> >>> org.apache.hadoop.hbase.client.RetriesExhaustedException:
> >>> Exceptions:
> >>> java.io.IOException: java.io.IOException:
> >>> java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
> >>> capacity of the array: 32
> >>> at
> >>>
> >>>
> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
> >>>  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
> >>> at
> >>>
> >>>
> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
> >>>  at
> >>>
> >>>
> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
> >>> at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
> >>>  at sun.reflec...
> >>>
> >>>
> >>> I guess I have tried all possible combinations of datatypes....I could
> >>> not
> >>> even find a decent example of incrementColumnValue()
> >>>
> >>
> >>
> >
> >
> >
> >
>

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by sulabh choudhury <su...@gmail.com>.
I just realized that using the increment function creates another version,
with a new timestamp.
Is there a way we can use the previous TS, hence over writing the value ?

On Tue, Mar 29, 2011 at 9:38 AM, sulabh choudhury <su...@gmail.com> wrote:

> Thanks Jesse. Changing the 10 to 10L made it work.
>
> On Tue, Mar 29, 2011 at 8:59 AM, Jesse Hutton <je...@gmail.com>wrote:
>
>> Hi,
>>
>> It looks like the problem is that the initial value you're inserting in
>> the column is an int, while HTable#incrementColumnValue() expects a long.
>> Instead of:
>>
>>
>>> I enter data by :-
>>> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
>>> Bytes.toBytes(10))
>>>
>>
>> try:
>> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
>> Bytes.toBytes(10L));
>>
>> Jesse
>>
>>
>>>
>>> Now when I try to increment the value I have tried...
>>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
>>> Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
>>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
>>> Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>>>
>>> also
>>> val inc = new Increment(Bytes.toBytes("row" + 5))
>>> inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>>> mytable.increment(inc)
>>>
>>> In both of the cases, I get an error like
>>> org.apache.hadoop.hbase.client.RetriesExhaustedException:
>>> Exceptions:
>>> java.io.IOException: java.io.IOException:
>>> java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
>>> capacity of the array: 32
>>> at
>>>
>>> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
>>>  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
>>> at
>>>
>>> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
>>>  at
>>>
>>> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
>>> at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
>>>  at sun.reflec...
>>>
>>>
>>> I guess I have tried all possible combinations of datatypes....I could
>>> not
>>> even find a decent example of incrementColumnValue()
>>>
>>
>>
>
>
>
>

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by sulabh choudhury <su...@gmail.com>.
Thanks Jesse. Changing the 10 to 10L made it work.

On Tue, Mar 29, 2011 at 8:59 AM, Jesse Hutton <je...@gmail.com>wrote:

> Hi,
>
> It looks like the problem is that the initial value you're inserting in the
> column is an int, while HTable#incrementColumnValue() expects a long.
> Instead of:
>
>
>> I enter data by :-
>> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
>> Bytes.toBytes(10))
>>
>
> try:
> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
> Bytes.toBytes(10L));
>
> Jesse
>
>
>>
>> Now when I try to increment the value I have tried...
>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
>> Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
>> mytable.incrementColumnValue(Bytes.toBytes("row5"),
>> Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>>
>> also
>> val inc = new Increment(Bytes.toBytes("row" + 5))
>> inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>> mytable.increment(inc)
>>
>> In both of the cases, I get an error like
>> org.apache.hadoop.hbase.client.RetriesExhaustedException:
>> Exceptions:
>> java.io.IOException: java.io.IOException:
>> java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
>> capacity of the array: 32
>> at
>>
>> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
>>  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
>> at
>>
>> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
>>  at
>>
>> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
>> at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
>>  at sun.reflec...
>>
>>
>> I guess I have tried all possible combinations of datatypes....I could not
>> even find a decent example of incrementColumnValue()
>>
>
>

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by Jesse Hutton <je...@gmail.com>.
Hi,

It looks like the problem is that the initial value you're inserting in the
column is an int, while HTable#incrementColumnValue() expects a long.
Instead of:


> I enter data by :-
> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
> Bytes.toBytes(10))
>

try:
theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
Bytes.toBytes(10L));

Jesse


>
> Now when I try to increment the value I have tried...
> mytable.incrementColumnValue(Bytes.toBytes("row5"),
> Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
> mytable.incrementColumnValue(Bytes.toBytes("row5"),
> Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>
> also
> val inc = new Increment(Bytes.toBytes("row" + 5))
> inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
> mytable.increment(inc)
>
> In both of the cases, I get an error like
> org.apache.hadoop.hbase.client.RetriesExhaustedException:
> Exceptions:
> java.io.IOException: java.io.IOException:
> java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
> capacity of the array: 32
> at
>
> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
>  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
> at
>
> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
>  at
>
> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
> at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
>  at sun.reflec...
>
>
> I guess I have tried all possible combinations of datatypes....I could not
> even find a decent example of incrementColumnValue()
>

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by sulabh choudhury <su...@gmail.com>.
On Tue, Mar 29, 2011 at 8:56 AM, Stack <st...@duboce.net> wrote:

> Try
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HTable.html#increment(org.apache.hadoop.hbase.client.Increment)
> instead.  It looks like its whats taking over from ICV (and we should
> be decrementing ICV).
> St.Ack
>
> I have tried implementing the Increment function, but I was getting the
same error.


>  On Tue, Mar 29, 2011 at 8:22 AM, sulabh choudhury <su...@gmail.com>
> wrote:
> > Hi,
> >
> > Unable to use the Increment function, can anybody suggest what am I doing
> > wrong...
> >
> > I enter data by :-
> > theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
> > Bytes.toBytes(10))
> >
> > Now when I try to increment the value I have tried...
> > mytable.incrementColumnValue(Bytes.toBytes("row5"),
> > Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
> > mytable.incrementColumnValue(Bytes.toBytes("row5"),
> > Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
> >
> > also
> > val inc = new Increment(Bytes.toBytes("row" + 5))
> > inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
> > mytable.increment(inc)
> >
> > In both of the cases, I get an error like
> > org.apache.hadoop.hbase.client.RetriesExhaustedException:
> > Exceptions:
> > java.io.IOException: java.io.IOException:
> > java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
> > capacity of the array: 32
> > at
> >
> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
> >  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
> > at
> >
> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
> >  at
> >
> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
> > at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
> >  at sun.reflec...
> >
> >
> > I guess I have tried all possible combinations of datatypes....I could
> not
> > even find a decent example of incrementColumnValue()
> >
>

Re: java.lang.IllegalArgumentException in incrementColumnValue and Increment

Posted by Stack <st...@duboce.net>.
Try http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HTable.html#increment(org.apache.hadoop.hbase.client.Increment)
instead.  It looks like its whats taking over from ICV (and we should
be decrementing ICV).
St.Ack

On Tue, Mar 29, 2011 at 8:22 AM, sulabh choudhury <su...@gmail.com> wrote:
> Hi,
>
> Unable to use the Increment function, can anybody suggest what am I doing
> wrong...
>
> I enter data by :-
> theput.add(Bytes.toBytes("uid"),Bytes.toBytes("1"), 1301087829999L + t,
> Bytes.toBytes(10))
>
> Now when I try to increment the value I have tried...
> mytable.incrementColumnValue(Bytes.toBytes("row5"),
> Bytes.toBytes("uid"),Bytes.toBytes("1"),Bytes.toBytes(1))
> mytable.incrementColumnValue(Bytes.toBytes("row5"),
> Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
>
> also
> val inc = new Increment(Bytes.toBytes("row" + 5))
> inc.addColumn(Bytes.toBytes("uid"),Bytes.toBytes("1"),1)
> mytable.increment(inc)
>
> In both of the cases, I get an error like
> org.apache.hadoop.hbase.client.RetriesExhaustedException:
> Exceptions:
> java.io.IOException: java.io.IOException:
> java.lang.IllegalArgumentException: offset (28) + length (8) exceed the
> capacity of the array: 32
> at
> org.apache.hadoop.hbase.util.Bytes.explainWrongLengthOrOffset(Bytes.java:502)
>  at org.apache.hadoop.hbase.util.Bytes.toLong(Bytes.java:480)
> at
> org.apache.hadoop.hbase.regionserver.HRegion.incrementColumnValue(HRegion.java:3134)
>  at
> org.apache.hadoop.hbase.regionserver.HRegionServer.incrementColumnValue(HRegionServer.java:2486)
> at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
>  at sun.reflec...
>
>
> I guess I have tried all possible combinations of datatypes....I could not
> even find a decent example of incrementColumnValue()
>