HBASE-10486: ProtobufUtil Append & Increment deserialization lost cell level timestamp
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1566505 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
74ab28497d
commit
b54f49e633
|
@ -683,7 +683,7 @@ public final class ProtobufUtil {
|
||||||
if (qv.hasTags()) {
|
if (qv.hasTags()) {
|
||||||
tags = qv.getTags().toByteArray();
|
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));
|
KeyValue.Type.Put, value, tags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,7 +761,7 @@ public final class ProtobufUtil {
|
||||||
if (qv.hasTags()) {
|
if (qv.hasTags()) {
|
||||||
tags = qv.getTags().toByteArray();
|
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));
|
KeyValue.Type.Put, value, tags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,19 +105,22 @@ public class TestProtobufUtil {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAppend() throws IOException {
|
public void testAppend() throws IOException {
|
||||||
|
long timeStamp = 111111;
|
||||||
MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
|
MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
|
||||||
mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
|
mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
|
||||||
mutateBuilder.setMutateType(MutationType.APPEND);
|
mutateBuilder.setMutateType(MutationType.APPEND);
|
||||||
mutateBuilder.setTimestamp(111111);
|
mutateBuilder.setTimestamp(timeStamp);
|
||||||
ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
|
ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
|
||||||
valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
|
valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
|
||||||
QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
|
QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
|
||||||
qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
|
qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
|
||||||
qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
|
qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
|
||||||
|
qualifierBuilder.setTimestamp(timeStamp);
|
||||||
valueBuilder.addQualifierValue(qualifierBuilder.build());
|
valueBuilder.addQualifierValue(qualifierBuilder.build());
|
||||||
qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
|
qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
|
||||||
qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
|
qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
|
||||||
valueBuilder.addQualifierValue(qualifierBuilder.build());
|
valueBuilder.addQualifierValue(qualifierBuilder.build());
|
||||||
|
qualifierBuilder.setTimestamp(timeStamp);
|
||||||
mutateBuilder.addColumnValue(valueBuilder.build());
|
mutateBuilder.addColumnValue(valueBuilder.build());
|
||||||
|
|
||||||
MutationProto proto = mutateBuilder.build();
|
MutationProto proto = mutateBuilder.build();
|
||||||
|
@ -131,15 +134,8 @@ public class TestProtobufUtil {
|
||||||
Append append = ProtobufUtil.toAppend(proto, null);
|
Append append = ProtobufUtil.toAppend(proto, null);
|
||||||
|
|
||||||
// append always use the latest timestamp,
|
// append always use the latest timestamp,
|
||||||
// add the timestamp to the original mutate
|
// reset the timestamp to the original mutate
|
||||||
long timestamp = append.getTimeStamp();
|
mutateBuilder.setTimestamp(append.getTimeStamp());
|
||||||
mutateBuilder.setTimestamp(timestamp);
|
|
||||||
for (ColumnValue.Builder column: mutateBuilder.getColumnValueBuilderList()) {
|
|
||||||
for (QualifierValue.Builder qualifier:
|
|
||||||
column.getQualifierValueBuilderList()) {
|
|
||||||
qualifier.setTimestamp(timestamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append));
|
assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.APPEND, append));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue