anoopsjohn commented on a change in pull request #3232:
URL: https://github.com/apache/hbase/pull/3232#discussion_r642014744



##########
File path: 
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java
##########
@@ -135,9 +135,7 @@ public CellWritableComparable(Cell kv) {
 
     @Override
     public void write(DataOutput out) throws IOException {
-      out.writeInt(PrivateCellUtil.estimatedSerializedSizeOfKey(kv));
-      out.writeInt(0);
-      PrivateCellUtil.writeFlatKey(kv, out);
+        KeyValueUtil.write(new KeyValue(kv), out);

Review comment:
       Te patch in HBASE-18649 changed this part and made to write only the key 
part of the cell (rowkey + cf + q + ts + type) instead of the entire KV.  So it 
writes key length
   out.writeInt(PrivateCellUtil.estimatedSerializedSizeOfKey(kv));
   And then value len as 0
   and then key part.
   But this is not compatible with counter part read where it expects a prefix 
int part which says the overall length of this KV (Ya what we wrote is still a 
KV , or call it Cell, where value is empty).   
   So I agree to the fact that this never worked. 
   We can not get rid of out.writeInt(0).
   On the other hand we have to write this entire KV length what we are going 
to write.  This is key len + value len(0) + 4 + 4  (we write these extra 4 
bytes twice for these 2 lengths too)
   
   int keyLen = CellUtil.estimatedSerializedSizeOfKey(kv);
   int valueLen = 0; // We avoid writing value here. So just serialize as if an 
empty value.
   out.writeInt(keyLen+ valueLen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE);
   out.writeInt(keyLen);
   out.writeInt(valueLen);
   CellUtil.writeFlatKey(kv, out);
   
   Not sure whether we already have some util method for this.  Else worth 
adding?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to