diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java index 927d675a2ab..55337357a13 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java @@ -683,7 +683,7 @@ public final class ProtobufUtil { if (qv.hasTags()) { tags = qv.getTags().toByteArray(); } - append.add(CellUtil.createCell(row, family, qualifier, append.getTimeStamp(), + append.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(), KeyValue.Type.Put, value, tags)); } } @@ -761,7 +761,7 @@ public final class ProtobufUtil { if (qv.hasTags()) { tags = qv.getTags().toByteArray(); } - increment.add(CellUtil.createCell(row, family, qualifier, increment.getTimeStamp(), + increment.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(), KeyValue.Type.Put, value, tags)); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java index db3f97a5542..0aa011bb767 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java @@ -105,19 +105,22 @@ public class TestProtobufUtil { */ @Test public void testAppend() throws IOException { + long timeStamp = 111111; MutationProto.Builder mutateBuilder = MutationProto.newBuilder(); mutateBuilder.setRow(ByteString.copyFromUtf8("row")); mutateBuilder.setMutateType(MutationType.APPEND); - mutateBuilder.setTimestamp(111111); + mutateBuilder.setTimestamp(timeStamp); ColumnValue.Builder valueBuilder = ColumnValue.newBuilder(); valueBuilder.setFamily(ByteString.copyFromUtf8("f1")); QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder(); qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1")); qualifierBuilder.setValue(ByteString.copyFromUtf8("v1")); + qualifierBuilder.setTimestamp(timeStamp); valueBuilder.addQualifierValue(qualifierBuilder.build()); qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2")); qualifierBuilder.setValue(ByteString.copyFromUtf8("v2")); valueBuilder.addQualifierValue(qualifierBuilder.build()); + qualifierBuilder.setTimestamp(timeStamp); mutateBuilder.addColumnValue(valueBuilder.build()); MutationProto proto = mutateBuilder.build(); @@ -131,15 +134,8 @@ public class TestProtobufUtil { Append append = ProtobufUtil.toAppend(proto, null); // append always use the latest timestamp, - // add the timestamp to the original mutate - long timestamp = append.getTimeStamp(); - mutateBuilder.setTimestamp(timestamp); - for (ColumnValue.Builder column: mutateBuilder.getColumnValueBuilderList()) { - for (QualifierValue.Builder qualifier: - column.getQualifierValueBuilderList()) { - qualifier.setTimestamp(timestamp); - } - } + // reset the timestamp to the original mutate + mutateBuilder.setTimestamp(append.getTimeStamp()); assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append)); }