hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1354703 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Wed, 27 Jun 2012 20:10:51 GMT
Author: tedyu
Date: Wed Jun 27 20:10:50 2012
New Revision: 1354703

URL: http://svn.apache.org/viewvc?rev=1354703&view=rev
Log:
HBASE-6269 Lazyseek should use the maxSequenseId StoreFile's KeyValue as the latest KeyValue
(Xing Shi)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java?rev=1354703&r1=1354702&r2=1354703&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java
Wed Jun 27 20:10:50 2012
@@ -365,7 +365,7 @@ public class KeyValueHeap extends NonLaz
           // Compare the current scanner to the next scanner. We try to avoid
           // putting the current one back into the heap if possible.
           KeyValue nextKV = nextEarliestScanner.peek();
-          if (nextKV == null || comparator.compare(curKV, nextKV) <= 0) {
+          if (nextKV == null || comparator.compare(curKV, nextKV) < 0) {
             // We already have the scanner with the earliest KV, so return it.
             return kvScanner;
           }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1354703&r1=1354702&r2=1354703&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Wed Jun 27 20:10:50 2012
@@ -3708,6 +3708,67 @@ public class TestHRegion extends HBaseTe
     assertEquals(expected, appendResult);
     this.region = null;
   }
+
+  /**
+   * Test case to check put function with memstore flushing for same row, same ts
+   * @throws Exception
+   */
+  public void testPutWithMemStoreFlush() throws Exception {
+    Configuration conf = HBaseConfiguration.create();
+    String method = "testPutWithMemStoreFlush";
+    byte[] tableName = Bytes.toBytes(method);
+    byte[] family = Bytes.toBytes("family");;
+    byte[] qualifier = Bytes.toBytes("qualifier");
+    byte[] row = Bytes.toBytes("putRow");
+    byte[] value = null;
+    this.region = initHRegion(tableName, method, conf, family);
+    Put put = null;
+    Get get = null;
+    List<KeyValue> kvs = null;
+    Result res = null;
+
+    put = new Put(row);
+    value = Bytes.toBytes("value0");
+    put.add(family, qualifier, 1234567l, value);
+    region.put(put);
+    get = new Get(row);
+    get.addColumn(family, qualifier);
+    get.setMaxVersions();
+    res = this.region.get(get, null);
+    kvs = res.getColumn(family, qualifier);
+    assertEquals(1, kvs.size());
+    assertEquals(Bytes.toBytes("value0"), kvs.get(0).getValue());
+
+    region.flushcache();
+    get = new Get(row);
+    get.addColumn(family, qualifier);
+    get.setMaxVersions();
+    res = this.region.get(get, null);
+    kvs = res.getColumn(family, qualifier);
+    assertEquals(1, kvs.size());
+    assertEquals(Bytes.toBytes("value0"), kvs.get(0).getValue());
+
+    put = new Put(row);
+    value = Bytes.toBytes("value1");
+    put.add(family, qualifier, 1234567l, value);
+    region.put(put);
+    get = new Get(row);
+    get.addColumn(family, qualifier);
+    get.setMaxVersions();
+    res = this.region.get(get, null);
+    kvs = res.getColumn(family, qualifier);
+    assertEquals(1, kvs.size());
+    assertEquals(Bytes.toBytes("value1"), kvs.get(0).getValue());
+
+    region.flushcache();
+    get = new Get(row);
+    get.addColumn(family, qualifier);
+    get.setMaxVersions();
+    res = this.region.get(get, null);
+    kvs = res.getColumn(family, qualifier);
+    assertEquals(1, kvs.size());
+    assertEquals(Bytes.toBytes("value1"), kvs.get(0).getValue());
+  }
   
   private void putData(int startRow, int numRows, byte [] qf,
       byte [] ...families)



Mime
View raw message