HBASE-12449 Use the max timestamp of current or old cell's timestamp in HRegion.append()

This commit is contained in:
Enis Soztutar 2014-11-18 11:34:49 -08:00
parent d3e7c3cfa9
commit b97c3daf90
1 changed files with 7 additions and 4 deletions

View File

@ -5390,9 +5390,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { //
if (idx < results.size()
&& CellUtil.matchingQualifier(results.get(idx), cell)) {
oldCell = results.get(idx);
long ts = Math.max(now, oldCell.getTimestamp());
// allocate an empty kv once
newCell = new KeyValue(row.length, cell.getFamilyLength(),
cell.getQualifierLength(), now, KeyValue.Type.Put,
cell.getQualifierLength(), ts, KeyValue.Type.Put,
oldCell.getValueLength() + cell.getValueLength(),
oldCell.getTagsLength() + cell.getTagsLength());
// copy in the value
@ -5603,8 +5604,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { //
boolean noWriteBack = (amount == 0);
Cell c = null;
long ts = now;
if (idx < results.size() && CellUtil.matchingQualifier(results.get(idx), kv)) {
c = results.get(idx);
ts = Math.max(now, c.getTimestamp());
if(c.getValueLength() == Bytes.SIZEOF_LONG) {
amount += Bytes.toLong(c.getValueArray(), c.getValueOffset(), Bytes.SIZEOF_LONG);
} else {
@ -5620,7 +5623,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { //
byte[] val = Bytes.toBytes(amount);
int oldCellTagsLen = (c == null) ? 0 : c.getTagsLength();
int incCellTagsLen = kv.getTagsLength();
Cell newKV = new KeyValue(row.length, family.getKey().length, q.length, now,
Cell newKV = new KeyValue(row.length, family.getKey().length, q.length, ts,
KeyValue.Type.Put, val.length, oldCellTagsLen + incCellTagsLen);
System.arraycopy(row, 0, newKV.getRowArray(), newKV.getRowOffset(), row.length);
System.arraycopy(family.getKey(), 0, newKV.getFamilyArray(), newKV.getFamilyOffset(),