diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java index a4b38571d1b..a06e0acc58c 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java @@ -21,17 +21,17 @@ import java.io.DataOutputStream; import java.io.IOException; import java.nio.ByteBuffer; -import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.SettableSequenceId; import org.apache.hadoop.hbase.KeyValue.KVComparator; import org.apache.hadoop.hbase.KeyValue.SamePrefixComparator; import org.apache.hadoop.hbase.KeyValue.Type; import org.apache.hadoop.hbase.KeyValueUtil; +import org.apache.hadoop.hbase.SettableSequenceId; +import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.io.HeapSize; import org.apache.hadoop.hbase.io.TagCompressionContext; import org.apache.hadoop.hbase.io.hfile.BlockType; @@ -331,7 +331,7 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder { protected static class ClonedSeekerState implements Cell, HeapSize, SettableSequenceId { private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT + (4 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG) + (7 * Bytes.SIZEOF_INT) - + (Bytes.SIZEOF_SHORT) + (2 * Bytes.SIZEOF_BYTE)); + + (Bytes.SIZEOF_SHORT) + (2 * Bytes.SIZEOF_BYTE) + (2 * ClassSize.ARRAY)); private byte[] keyOnlyBuffer; private ByteBuffer currentBuffer; private short rowLength; @@ -515,8 +515,7 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder { @Override public long heapSize() { - return FIXED_OVERHEAD + rowLength + familyLength + qualifierLength + valueLength + tagsLength - + KeyValue.TIMESTAMP_TYPE_SIZE; + return FIXED_OVERHEAD + rowLength + familyLength + qualifierLength + valueLength + tagsLength; } } diff --git a/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java index fb73443cc6c..2db0f29aa18 100644 --- a/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java +++ b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java @@ -24,13 +24,17 @@ import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.KVComparator; +import org.apache.hadoop.hbase.KeyValue.Type; import org.apache.hadoop.hbase.KeyValueUtil; import org.apache.hadoop.hbase.SettableSequenceId; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.codec.prefixtree.decode.DecoderFactory; import org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher; import org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition; +import org.apache.hadoop.hbase.io.HeapSize; import org.apache.hadoop.hbase.io.encoding.DataBlockEncoder.EncodedSeeker; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.ClassSize; /** * These methods have the same definition as any implementation of the EncodedSeeker. @@ -271,7 +275,10 @@ public class PrefixTreeSeeker implements EncodedSeeker { * of the key part is deep copied * */ - private static class ClonedPrefixTreeCell implements Cell, SettableSequenceId { + private static class ClonedPrefixTreeCell implements Cell, SettableSequenceId, HeapSize { + private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT + + (5 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG) + (4 * Bytes.SIZEOF_INT) + + (Bytes.SIZEOF_SHORT) + (2 * Bytes.SIZEOF_BYTE) + (5 * ClassSize.ARRAY)); private byte[] row; private short rowLength; private byte[] fam; @@ -282,7 +289,7 @@ public class PrefixTreeSeeker implements EncodedSeeker { private int valOffset; private int valLength; private byte[] tag; - private int tagLength; + private int tagsLength; private long ts; private long seqId; private byte type; @@ -302,7 +309,7 @@ public class PrefixTreeSeeker implements EncodedSeeker { this.qualLength = qualLength; this.tag = new byte[tagLength]; System.arraycopy(tag, tagOffset, this.tag, 0, tagLength); - this.tagLength = tagLength; + this.tagsLength = tagLength; this.val = val; this.valLength = valLength; this.valOffset = valOffset; @@ -409,7 +416,7 @@ public class PrefixTreeSeeker implements EncodedSeeker { @Override public int getTagsLength() { - return this.tagLength; + return this.tagsLength; } @Override @@ -438,7 +445,18 @@ public class PrefixTreeSeeker implements EncodedSeeker { @Override public String toString() { - return KeyValueUtil.copyToNewKeyValue(this).toString(); + String row = Bytes.toStringBinary(getRowArray(), getRowOffset(), getRowLength()); + String family = Bytes.toStringBinary(getFamilyArray(), getFamilyOffset(), getFamilyLength()); + String qualifier = Bytes.toStringBinary(getQualifierArray(), getQualifierOffset(), + getQualifierLength()); + String timestamp = String.valueOf((getTimestamp())); + return row + "/" + family + (family != null && family.length() > 0 ? ":" : "") + qualifier + + "/" + timestamp + "/" + Type.codeToType(type); + } + + @Override + public long heapSize() { + return FIXED_OVERHEAD + rowLength + famLength + qualLength + valLength + tagsLength; } } }