HBASE-17836 CellUtil#estimatedSerializedSizeOf is slow when input is ByteBufferCell
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1a701ce4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1a701ce4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1a701ce4 Branch: refs/heads/HBASE-16961 Commit: 1a701ce44484f45a8a07ea9826b84f0df6f1518e Parents: 48b2502 Author: Chia-Ping Tsai <chia7...@gmail.com> Authored: Sat Apr 1 13:50:01 2017 +0800 Committer: Chia-Ping Tsai <chia7...@gmail.com> Committed: Fri Apr 7 09:30:15 2017 +0800 ---------------------------------------------------------------------- .../src/main/java/org/apache/hadoop/hbase/CellUtil.java | 8 +++----- .../src/main/java/org/apache/hadoop/hbase/SplitLogTask.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/1a701ce4/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java ---------------------------------------------------------------------- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java index 6585173..e1bc969 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java @@ -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. http://git-wip-us.apache.org/repos/asf/hbase/blob/1a701ce4/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java index 03d5108..3ecaa86 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogTask.java @@ -86,7 +86,7 @@ public class SplitLogTask { public ServerName getServerName() { return this.originServer; } - + public ZooKeeperProtos.SplitLogTask.RecoveryMode getMode() { return this.mode; }