hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffr...@apache.org
Subject svn commit: r1566962 - in /hbase/branches/0.96: hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
Date Tue, 11 Feb 2014 02:27:17 GMT
Author: jeffreyz
Date: Tue Feb 11 02:27:17 2014
New Revision: 1566962

URL: http://svn.apache.org/r1566962
Log:
HBASE-10486: ProtobufUtil Append & Increment deserialization lost cell level timestamp

Modified:
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java?rev=1566962&r1=1566961&r2=1566962&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
(original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
Tue Feb 11 02:27:17 2014
@@ -661,7 +661,8 @@ public final class ProtobufUtil {
               "Missing required field: qualifer value");
           }
           byte[] value = qv.getValue().toByteArray();
-          append.add(family, qualifier, value);
+          append.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(),
+            KeyValue.Type.Put.getCode(), value));
         }
       }
     }
@@ -733,8 +734,8 @@ public final class ProtobufUtil {
           if (!qv.hasValue()) {
             throw new DoNotRetryIOException("Missing required field: qualifer value");
           }
-          long value = Bytes.toLong(qv.getValue().toByteArray());
-          increment.addColumn(family, qualifier, value);
+          increment.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(),
+            KeyValue.Type.Put.getCode(), qv.getValue().toByteArray()));
         }
       }
     }

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java?rev=1566962&r1=1566961&r2=1566962&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
(original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
Tue Feb 11 02:27:17 2014
@@ -104,19 +104,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();
@@ -130,15 +133,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));
   }
 



Mime
View raw message