Zhuoyue Huang created HBASE-25387:
-------------------------------------

             Summary: TagRewriteCell's getSerializedSize() method gets the size 
wrong
                 Key: HBASE-25387
                 URL: https://issues.apache.org/jira/browse/HBASE-25387
             Project: HBase
          Issue Type: Bug
    Affects Versions: 3.0.0-alpha-1
            Reporter: Zhuoyue Huang
            Assignee: Zhuoyue Huang


We found that the serialized size of Cell is inconsistent with the size 
actually written to ByteBuffer when the tag is empty.
{code:java}
Cell originalCell = ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY)
  .setRow(Bytes.toBytes("row"))
  .setFamily(Bytes.toBytes("family"))
  .setQualifier(Bytes.toBytes("qualifier"))
  .setTimestamp(HConstants.LATEST_TIMESTAMP)
  .setType(KeyValue.Type.Maximum.getCode())
  .setValue(Bytes.toBytes("value"))
  .build();

ByteBuffer byteBuffer = ByteBuffer.allocate(100);
Cell cell = PrivateCellUtil.createCell(originalCell, "".getBytes());
int lengthWritten = KeyValueUtil.appendTo(cell, byteBuffer, 0, true);
System.out.println("Cell serializedSize: " + cell.getSerializedSize());
System.out.println("Bytes written to ByteBuffer: " + lengthWritten);

ByteArrayOutputStream output = new ByteArrayOutputStream(100);
PrivateCellUtil.writeCell(cell, output, true);
System.out.println("Bytes written to OutputStream: " + output.size());
{code}
Run the above code to see the following output

 
{code:java}
Cell serializedSize: 45
Bytes written to ByteBuffer: 43
Bytes written to OutputStream: 45
{code}
 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to