From f41b539b9ddde76d652b970a26a5ccda0edd0e1b Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sat, 26 Nov 2016 00:44:17 +0800 Subject: [PATCH] HBASE-17086: Add comments to explain why Cell#getTagsLength() returns an int, rather than a short --- hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java index 626f041..53b319b 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/Cell.java @@ -170,6 +170,7 @@ public interface Cell { int getValueLength(); /** + * Contiguous raw bytes representing tags that may start at any index in the containing array. * @return the tags byte array */ byte[] getTagsArray(); @@ -180,6 +181,12 @@ public interface Cell { int getTagsOffset(); /** + * HBase internally uses 2 bytes to store tags length in Cell. + * As the tags length is always a non-negative number, to make good use of the sign bit, + * the max of tags length is defined as {@link TagUtil#MAX_TAGS_LENGTH}, which is 2 * Short.MAX_VALUE + 1 = 65535. + * As a result, the return type is int, because a short is not capable of handling that. + * Please note that even if the return type is int, the max tags length is far less than Integer.MAX_VALUE. + * * @return the total length of the tags in the Cell. */ int getTagsLength(); -- 2.9.3 (Apple Git-75)