HBASE-1798 [Regression] Unable to delete a row in the future

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@808238 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2009-08-27 00:57:38 +00:00
parent 210a157a95
commit e25e8b0363
4 changed files with 40 additions and 4 deletions

View File

@ -9,6 +9,7 @@ Release 0.21.0 - Unreleased
HBASE-1792 [Regression] Cannot save timestamp in the future
HBASE-1793 [Regression] HTable.get/getRow with a ts is broken
HBASE-1698 Review documentation for o.a.h.h.mapreduce
HBASE-1798 [Regression] Unable to delete a row in the future
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -819,9 +819,8 @@ public class KeyValue implements Writable, HeapSize {
}
public boolean updateLatestStamp(final byte [] now) {
if(this.isLatestTimestamp()) {
int tsOffset = getTimestampOffset();
if(Bytes.compareTo(now, 0, Bytes.SIZEOF_LONG,
this.bytes, tsOffset, Bytes.SIZEOF_LONG) < 0) {
System.arraycopy(now, 0, this.bytes, tsOffset, Bytes.SIZEOF_LONG);
return true;
}

View File

@ -1108,7 +1108,8 @@ public class HRegion implements HConstants, HeapSize { // , Writable{
//Check to see if this is a deleteRow insert
if(delete.getFamilyMap().isEmpty()){
for(byte [] family : regionInfo.getTableDesc().getFamiliesKeys()){
delete.deleteFamily(family);
// Don't eat the timestamp
delete.deleteFamily(family, delete.getTimeStamp());
}
} else {
for(byte [] family : delete.getFamilyMap().keySet()) {

View File

@ -293,6 +293,41 @@ public class TestHRegion extends HBaseTestCase {
assertEquals(1, result.size());
}
public void testDeleteRowWithFutureTs() throws IOException {
byte [] tableName = Bytes.toBytes("testtable");
byte [] fam = Bytes.toBytes("info");
byte [][] families = {fam};
String method = this.getName();
initHRegion(tableName, method, families);
byte [] row = Bytes.toBytes("table_name");
// column names
byte [] serverinfo = Bytes.toBytes("serverinfo");
// add data in the far future
Put put = new Put(row);
put.add(fam, serverinfo, HConstants.LATEST_TIMESTAMP-5,Bytes.toBytes("value"));
region.put(put);
// now delete something in the present
Delete delete = new Delete(row);
region.delete(delete, null, true);
// make sure we still see our data
Get get = new Get(row).addColumn(fam, serverinfo);
Result result = region.get(get, null);
assertEquals(1, result.size());
// delete the future row
delete = new Delete(row,HConstants.LATEST_TIMESTAMP-3,null);
region.delete(delete, null, true);
// make sure it is gone
get = new Get(row).addColumn(fam, serverinfo);
result = region.get(get, null);
assertEquals(0, result.size());
}
public void testScanner_DeleteOneFamilyNotAnother() throws IOException {
byte [] tableName = Bytes.toBytes("test_table");
byte [] fam1 = Bytes.toBytes("columnA");