hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1371045 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/HRegion.java test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Thu, 09 Aug 2012 06:21:45 GMT
Author: larsh
Date: Thu Aug  9 06:21:45 2012
New Revision: 1371045

URL: http://svn.apache.org/viewvc?rev=1371045&view=rev
Log:
HBASE-6520 MSLab May cause the Bytes.toLong not work correctly for increment (ShiXing)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1371045&r1=1371044&r2=1371045&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Thu
Aug  9 06:21:45 2012
@@ -4579,7 +4579,7 @@ public class HRegion implements HeapSize
             if (idx < results.size() &&
                 results.get(idx).matchingQualifier(column.getKey())) {
               KeyValue kv = results.get(idx);
-              amount += Bytes.toLong(kv.getBuffer(), kv.getValueOffset());
+              amount += Bytes.toLong(kv.getBuffer(), kv.getValueOffset(), kv.getValueLength());
               idx++;
             }
 

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1371045&r1=1371044&r2=1371045&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Thu Aug  9 06:21:45 2012
@@ -2602,6 +2602,38 @@ public class TestHRegion extends HBaseTe
     }
   }
 
+  public void testIncrement_WrongInitialSize() throws IOException {
+    this.region = initHRegion(tableName, getName(), fam1);
+    try {
+      byte[] row1 = Bytes.add(Bytes.toBytes("1234"), Bytes.toBytes(0L));
+      long row1Field1 = 0;
+      int row1Field2 = 1;
+      Put put1 = new Put(row1);
+      put1.add(fam1, qual1, Bytes.toBytes(row1Field1));
+      put1.add(fam1, qual2, Bytes.toBytes(row1Field2));
+      region.put(put1);
+      Increment increment = new Increment(row1);
+      increment.addColumn(fam1, qual1, 1);
+
+      //here we should be successful as normal
+      region.increment(increment, null, true);
+      assertICV(row1, fam1, qual1, row1Field1 + 1);
+
+      //failed to increment
+      increment = new Increment(row1);
+      increment.addColumn(fam1, qual2, 1);
+      try {
+        region.increment(increment, null, true);
+        fail("Expected to fail here");
+      } catch (Exception exception) {
+        // Expected.
+      }
+      assertICV(row1, fam1, qual2, row1Field2);
+    } finally {
+      HRegion.closeHRegion(this.region);
+      this.region = null;
+    }
+  }
   private void assertICV(byte [] row,
                          byte [] familiy,
                          byte[] qualifier,



Mime
View raw message