HBASE-1781 Weird behavior of WildcardColumnTracker.checkColumn(),

looks like recursive loop


git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@832659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2009-11-04 05:10:56 +00:00
parent 88c5a74d7c
commit c25e5e20e1
3 changed files with 149 additions and 119 deletions

View File

@ -92,6 +92,8 @@ Release 0.21.0 - Unreleased
HBASE-1919 code: HRS.delete seems to ignore exceptions it shouldnt HBASE-1919 code: HRS.delete seems to ignore exceptions it shouldnt
HBASE-1951 Stack overflow when calling HTable.checkAndPut() HBASE-1951 Stack overflow when calling HTable.checkAndPut()
when deleting a lot of values when deleting a lot of values
HBASE-1781 Weird behavior of WildcardColumnTracker.checkColumn(),
looks like recursive loop
IMPROVEMENTS IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable HBASE-1760 Cleanup TODOs in HTable

View File

@ -89,6 +89,8 @@ public class WildcardColumnTracker implements ColumnTracker {
* @return MatchCode telling QueryMatcher what action to take * @return MatchCode telling QueryMatcher what action to take
*/ */
public MatchCode checkColumn(byte [] bytes, int offset, int length) { public MatchCode checkColumn(byte [] bytes, int offset, int length) {
boolean recursive = false;
do {
// Nothing to match against, add to new and include // Nothing to match against, add to new and include
if(this.column == null && this.newColumn == null) { if(this.column == null && this.newColumn == null) {
@ -120,7 +122,9 @@ public class WildcardColumnTracker implements ColumnTracker {
return MatchCode.INCLUDE; return MatchCode.INCLUDE;
} }
this.newColumn = newColumns.get(newIndex); this.newColumn = newColumns.get(newIndex);
return checkColumn(bytes, offset, length); //return checkColumn(bytes, offset, length);
recursive = true;
continue;
} }
// ret >= 1 // ret >= 1
@ -155,7 +159,9 @@ public class WildcardColumnTracker implements ColumnTracker {
return MatchCode.INCLUDE; return MatchCode.INCLUDE;
} }
this.column = columns.get(index); this.column = columns.get(index);
return checkColumn(bytes, offset, length); //return checkColumn(bytes, offset, length);
recursive = true;
continue;
} }
// ret >= 1 // ret >= 1
@ -193,7 +199,9 @@ public class WildcardColumnTracker implements ColumnTracker {
} else { } else {
this.column = columns.get(index); this.column = columns.get(index);
} }
return checkColumn(bytes, offset, length); //return checkColumn(bytes, offset, length);
recursive = true;
continue;
} }
// ret >= 1 // ret >= 1
@ -226,7 +234,9 @@ public class WildcardColumnTracker implements ColumnTracker {
} else { } else {
this.newColumn = newColumns.get(newIndex); this.newColumn = newColumns.get(newIndex);
} }
return checkColumn(bytes, offset, length); //return checkColumn(bytes, offset, length);
recursive = true;
continue;
} }
// ret >= 1 // ret >= 1
@ -235,6 +245,7 @@ public class WildcardColumnTracker implements ColumnTracker {
newColumns.add(new ColumnCount(bytes, offset, length, 1)); newColumns.add(new ColumnCount(bytes, offset, length, 1));
return MatchCode.INCLUDE; return MatchCode.INCLUDE;
} }
} while(recursive);
// No match happened, add to new and include // No match happened, add to new and include
newColumns.add(new ColumnCount(bytes, offset, length, 1)); newColumns.add(new ColumnCount(bytes, offset, length, 1));

View File

@ -330,6 +330,23 @@ implements HConstants {
} }
} }
// HBASE-1781
public void testStackOverflow(){
int maxVersions = 1;
ColumnTracker wild = new WildcardColumnTracker(maxVersions);
for(int i = 0; i < 100000; i+=2) {
byte [] col = Bytes.toBytes("col"+i);
wild.checkColumn(col, 0, col.length);
}
wild.update();
for(int i = 1; i < 100000; i+=2) {
byte [] col = Bytes.toBytes("col"+i);
wild.checkColumn(col, 0, col.length);
}
}
} }