You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Lars Hofhansl (JIRA)" <ji...@apache.org> on 2012/10/27 05:17:14 UTC
[jira] [Updated] (HBASE-6846) BitComparator bug -
ArrayIndexOutOfBoundsException
[ https://issues.apache.org/jira/browse/HBASE-6846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lars Hofhansl updated HBASE-6846:
---------------------------------
Description:
The HBase 0.94.1 BitComparator introduced a bug in the method "compareTo":
{code}
@Override
public int compareTo(byte[] value, int offset, int length) {
if (length != this.value.length) {
return 1;
}
int b = 0;
//Iterating backwards is faster because we can quit after one non-zero byte.
for (int i = value.length - 1; i >= 0 && b == 0; i--) {
switch (bitOperator) {
case AND:
b = (this.value[i] & value[i+offset]) & 0xff;
break;
case OR:
b = (this.value[i] | value[i+offset]) & 0xff;
break;
case XOR:
b = (this.value[i] ^ value[i+offset]) & 0xff;
break;
}
}
return b == 0 ? 1 : 0;
}
{code}
I've encountered this problem when using a BitComparator with a configured this.value.length=8, and in the HBase table there were KeyValues with keyValue.getBuffer().length=207911 bytes. In this case:
{code}
for (int i = 207910; i >= 0 && b == 0; i--) {
switch (bitOperator) {
case AND:
b = (this.value[207910] ... ==> ArrayIndexOutOfBoundsException
break;
{code}
That loop should use:
{code}
for (int i = length - 1; i >= 0 && b == 0; i--) { (or this.value.length.)
{code}
Should I provide a patch for correcting the problem?
was:
The HBase 0.94.1 BitComparator introduced a bug in the method "compareTo":
@Override
public int compareTo(byte[] value, int offset, int length) {
if (length != this.value.length) {
return 1;
}
int b = 0;
//Iterating backwards is faster because we can quit after one non-zero byte.
for (int i = value.length - 1; i >= 0 && b == 0; i--) {
switch (bitOperator) {
case AND:
b = (this.value[i] & value[i+offset]) & 0xff;
break;
case OR:
b = (this.value[i] | value[i+offset]) & 0xff;
break;
case XOR:
b = (this.value[i] ^ value[i+offset]) & 0xff;
break;
}
}
return b == 0 ? 1 : 0;
}
I've encountered this problem when using a BitComparator with a configured this.value.length=8, and in the HBase table there were KeyValues with keyValue.getBuffer().length=207911 bytes. In this case:
for (int i = 207910; i >= 0 && b == 0; i--) {
switch (bitOperator) {
case AND:
b = (this.value[207910] ... ==> ArrayIndexOutOfBoundsException
break;
That loop should use:
for (int i = length - 1; i >= 0 && b == 0; i--) { (or this.value.length.)
Should I provide a patch for correcting the problem?
> BitComparator bug - ArrayIndexOutOfBoundsException
> --------------------------------------------------
>
> Key: HBASE-6846
> URL: https://issues.apache.org/jira/browse/HBASE-6846
> Project: HBase
> Issue Type: Bug
> Components: Filters
> Affects Versions: 0.94.1
> Environment: HBase 0.94.1 + Hadoop 2.0.0-cdh4.0.1
> Reporter: Lucian George Iordache
> Attachments: HBASE-6846.patch
>
>
> The HBase 0.94.1 BitComparator introduced a bug in the method "compareTo":
> {code}
> @Override
> public int compareTo(byte[] value, int offset, int length) {
> if (length != this.value.length) {
> return 1;
> }
> int b = 0;
> //Iterating backwards is faster because we can quit after one non-zero byte.
> for (int i = value.length - 1; i >= 0 && b == 0; i--) {
> switch (bitOperator) {
> case AND:
> b = (this.value[i] & value[i+offset]) & 0xff;
> break;
> case OR:
> b = (this.value[i] | value[i+offset]) & 0xff;
> break;
> case XOR:
> b = (this.value[i] ^ value[i+offset]) & 0xff;
> break;
> }
> }
> return b == 0 ? 1 : 0;
> }
> {code}
> I've encountered this problem when using a BitComparator with a configured this.value.length=8, and in the HBase table there were KeyValues with keyValue.getBuffer().length=207911 bytes. In this case:
> {code}
> for (int i = 207910; i >= 0 && b == 0; i--) {
> switch (bitOperator) {
> case AND:
> b = (this.value[207910] ... ==> ArrayIndexOutOfBoundsException
> break;
> {code}
> That loop should use:
> {code}
> for (int i = length - 1; i >= 0 && b == 0; i--) { (or this.value.length.)
> {code}
> Should I provide a patch for correcting the problem?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira