HBASE-6265 Calling getTimestamp() on a KV in cp.prePut() causes KV not to be flushed
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1356106 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cbd82f0440
commit
40dc5d71f8
|
@ -1165,6 +1165,8 @@ public class KeyValue implements Writable, HeapSize {
|
||||||
if (this.isLatestTimestamp()) {
|
if (this.isLatestTimestamp()) {
|
||||||
int tsOffset = getTimestampOffset();
|
int tsOffset = getTimestampOffset();
|
||||||
System.arraycopy(now, 0, this.bytes, tsOffset, Bytes.SIZEOF_LONG);
|
System.arraycopy(now, 0, this.bytes, tsOffset, Bytes.SIZEOF_LONG);
|
||||||
|
// clear cache or else getTimestamp() possibly returns an old value
|
||||||
|
timestampCache = -1L;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -504,6 +504,21 @@ public class TestKeyValue extends TestCase {
|
||||||
assertTrue(Bytes.equals(kv1.getRow(), kv2.getRow()));
|
assertTrue(Bytes.equals(kv1.getRow(), kv2.getRow()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that getTimestamp() does always return the proper timestamp, even after updating it.
|
||||||
|
* See HBASE-6265.
|
||||||
|
*/
|
||||||
|
public void testGetTimestamp() {
|
||||||
|
KeyValue kv = new KeyValue(Bytes.toBytes("myRow"), Bytes.toBytes("myCF"),
|
||||||
|
Bytes.toBytes("myQualifier"), HConstants.LATEST_TIMESTAMP,
|
||||||
|
Bytes.toBytes("myValue"));
|
||||||
|
long time1 = kv.getTimestamp();
|
||||||
|
kv.updateLatestStamp(Bytes.toBytes(12345L));
|
||||||
|
long time2 = kv.getTimestamp();
|
||||||
|
assertEquals(HConstants.LATEST_TIMESTAMP, time1);
|
||||||
|
assertEquals(12345L, time2);
|
||||||
|
}
|
||||||
|
|
||||||
@org.junit.Rule
|
@org.junit.Rule
|
||||||
public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
|
public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
|
||||||
new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
|
new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
|
||||||
|
|
Loading…
Reference in New Issue