HBASE-17836 CellUtil#estimatedSerializedSizeOf is slow when input is ByteBufferCell

This commit is contained in:
Chia-Ping Tsai 2017-04-01 13:50:01 +08:00
parent 48b2502a5f
commit 1a701ce444
2 changed files with 4 additions and 6 deletions

View File

@ -1385,12 +1385,10 @@ public final class CellUtil {
* @return Estimate of the <code>cell</code> size in bytes.
*/
public static int estimatedSerializedSizeOf(final Cell cell) {
// If a KeyValue, we can give a good estimate of size.
if (cell instanceof KeyValue) {
return ((KeyValue)cell).getLength() + Bytes.SIZEOF_INT;
if (cell instanceof ExtendedCell) {
return ((ExtendedCell) cell).getSerializedSize(true) + Bytes.SIZEOF_INT;
}
// TODO: Should we add to Cell a sizeOf? Would it help? Does it make sense if Cell is
// prefix encoded or compressed?
return getSumOfCellElementLengths(cell) +
// Use the KeyValue's infrastructure size presuming that another implementation would have
// same basic cost.

View File

@ -86,7 +86,7 @@ public class SplitLogTask {
public ServerName getServerName() {
return this.originServer;
}
public ZooKeeperProtos.SplitLogTask.RecoveryMode getMode() {
return this.mode;
}