HBASE-6269 Lazyseek should use the maxSequenseId StoreFile's KeyValue as the latest KeyValue (Xing Shi)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1354703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-06-27 20:10:50 +00:00
parent dc9223f3dd
commit 132c4fdc14
2 changed files with 62 additions and 1 deletions

View File

@ -365,7 +365,7 @@ public class KeyValueHeap extends NonLazyKeyValueScanner
// 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;
}

View File

@ -3708,6 +3708,67 @@ public class TestHRegion extends HBaseTestCase {
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)