hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject git commit: HBASE-12281 ClonedPrefixTreeCell should implement HeapSize (Ram)
Date Tue, 21 Oct 2014 14:17:04 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 67d1cee2d -> a4169e7b0


HBASE-12281 ClonedPrefixTreeCell should implement HeapSize (Ram)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a4169e7b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a4169e7b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a4169e7b

Branch: refs/heads/branch-1
Commit: a4169e7b0408d217e98c34edb2579c1a9bc89ba9
Parents: 67d1cee
Author: Ramkrishna <ramkrishna.s.vasudevan@intel.com>
Authored: Tue Oct 21 19:46:31 2014 +0530
Committer: Ramkrishna <ramkrishna.s.vasudevan@intel.com>
Committed: Tue Oct 21 19:46:31 2014 +0530

----------------------------------------------------------------------
 .../io/encoding/BufferedDataBlockEncoder.java   |  9 +++----
 .../codec/prefixtree/PrefixTreeSeeker.java      | 28 ++++++++++++++++----
 2 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a4169e7b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
----------------------------------------------------------------------
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 a4b3857..a06e0ac 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;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4169e7b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java
----------------------------------------------------------------------
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 fb73443..2db0f29 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;
     }
   }
 }


Mime
View raw message