hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1301240 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/
Date Thu, 15 Mar 2012 22:11:27 GMT
Author: tedyu
Date: Thu Mar 15 22:11:26 2012
New Revision: 1301240

URL: http://svn.apache.org/viewvc?rev=1301240&view=rev
Log:
HBASE-5579 A Delete Version could mask other values (Daniel Ferro)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java?rev=1301240&r1=1301239&r2=1301240&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/ScanDeleteTracker.java
Thu Mar 15 22:11:26 2012
@@ -21,7 +21,6 @@
 package org.apache.hadoop.hbase.regionserver;
 
 import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.regionserver.DeleteTracker.DeleteResult;
 import org.apache.hadoop.hbase.util.Bytes;
 
 /**
@@ -41,7 +40,8 @@ import org.apache.hadoop.hbase.util.Byte
  */
 public class ScanDeleteTracker implements DeleteTracker {
 
-  private long familyStamp = -1L;
+  private boolean hasFamilyStamp = false;
+  private long familyStamp = 0L;
   private byte [] deleteBuffer = null;
   private int deleteOffset = 0;
   private int deleteLength = 0;
@@ -69,8 +69,9 @@ public class ScanDeleteTracker implement
   @Override
   public void add(byte[] buffer, int qualifierOffset, int qualifierLength,
       long timestamp, byte type) {
-    if (timestamp > familyStamp) {
+    if (!hasFamilyStamp || timestamp > familyStamp) {
       if (type == KeyValue.Type.DeleteFamily.getCode()) {
+        hasFamilyStamp = true;
         familyStamp = timestamp;
         return;
       }
@@ -105,7 +106,7 @@ public class ScanDeleteTracker implement
   @Override
   public DeleteResult isDeleted(byte [] buffer, int qualifierOffset,
       int qualifierLength, long timestamp) {
-    if (timestamp <= familyStamp) {
+    if (hasFamilyStamp && timestamp <= familyStamp) {
       return DeleteResult.FAMILY_DELETED;
     }
 
@@ -144,12 +145,13 @@ public class ScanDeleteTracker implement
 
   @Override
   public boolean isEmpty() {
-    return deleteBuffer == null && familyStamp == 0;
+    return deleteBuffer == null && !hasFamilyStamp;
   }
 
   @Override
   // called between every row.
   public void reset() {
+    hasFamilyStamp = false;
     familyStamp = 0L;
     deleteBuffer = null;
   }

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java?rev=1301240&r1=1301239&r2=1301240&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompaction.java
Thu Mar 15 22:11:26 2012
@@ -377,11 +377,10 @@ public class TestCompaction extends HBas
     deleteVersion.deleteColumn(fam2, col2, 1);
     /*
      * the table has 4 versions: 0, 1, 2, and 3.
-     * 0 does not count.
      * We delete 1.
-     * Should have 2 remaining.
+     * Should have 3 remaining.
      */
-    testMinorCompactionWithDelete(deleteVersion, 2);
+    testMinorCompactionWithDelete(deleteVersion, 3);
   }
 
   /*

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java?rev=1301240&r1=1301239&r2=1301240&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanDeleteTracker.java
Thu Mar 15 22:11:26 2012
@@ -110,6 +110,19 @@ public class TestScanDeleteTracker exten
     assertEquals(false ,sdt.isEmpty());
   }
 
+  public void testDelete_KeepVersionZero(){
+    byte [] qualifier = Bytes.toBytes("qualifier");
+    deleteType = KeyValue.Type.Delete.getCode();
+
+    long deleteTimestamp = 10;
+    long valueTimestamp = 0;
+
+    sdt.reset();
+    sdt.add(qualifier, 0, qualifier.length, deleteTimestamp, deleteType);
+    DeleteResult ret = sdt.isDeleted(qualifier, 0, qualifier.length, valueTimestamp);
+    assertEquals(DeleteResult.NOT_DELETED, ret);
+  }
+
 
   @org.junit.Rule
   public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =



Mime
View raw message