HBASE-12281 ClonedPrefixTreeCell should implement HeapSize (Ram)
This commit is contained in:
parent
67d1cee2d8
commit
a4169e7b04
|
@ -21,17 +21,17 @@ import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.hbase.Cell;
|
import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellComparator;
|
import org.apache.hadoop.hbase.CellComparator;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
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.KVComparator;
|
||||||
import org.apache.hadoop.hbase.KeyValue.SamePrefixComparator;
|
import org.apache.hadoop.hbase.KeyValue.SamePrefixComparator;
|
||||||
import org.apache.hadoop.hbase.KeyValue.Type;
|
import org.apache.hadoop.hbase.KeyValue.Type;
|
||||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
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.HeapSize;
|
||||||
import org.apache.hadoop.hbase.io.TagCompressionContext;
|
import org.apache.hadoop.hbase.io.TagCompressionContext;
|
||||||
import org.apache.hadoop.hbase.io.hfile.BlockType;
|
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 {
|
protected static class ClonedSeekerState implements Cell, HeapSize, SettableSequenceId {
|
||||||
private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT
|
private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT
|
||||||
+ (4 * ClassSize.REFERENCE) + (2 * Bytes.SIZEOF_LONG) + (7 * Bytes.SIZEOF_INT)
|
+ (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 byte[] keyOnlyBuffer;
|
||||||
private ByteBuffer currentBuffer;
|
private ByteBuffer currentBuffer;
|
||||||
private short rowLength;
|
private short rowLength;
|
||||||
|
@ -515,8 +515,7 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long heapSize() {
|
public long heapSize() {
|
||||||
return FIXED_OVERHEAD + rowLength + familyLength + qualifierLength + valueLength + tagsLength
|
return FIXED_OVERHEAD + rowLength + familyLength + qualifierLength + valueLength + tagsLength;
|
||||||
+ KeyValue.TIMESTAMP_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,17 @@ import org.apache.hadoop.hbase.Cell;
|
||||||
import org.apache.hadoop.hbase.CellUtil;
|
import org.apache.hadoop.hbase.CellUtil;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
import org.apache.hadoop.hbase.KeyValue.KVComparator;
|
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.KeyValueUtil;
|
||||||
import org.apache.hadoop.hbase.SettableSequenceId;
|
import org.apache.hadoop.hbase.SettableSequenceId;
|
||||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.codec.prefixtree.decode.DecoderFactory;
|
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.decode.PrefixTreeArraySearcher;
|
||||||
import org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition;
|
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.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.
|
* 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
|
* 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 byte[] row;
|
||||||
private short rowLength;
|
private short rowLength;
|
||||||
private byte[] fam;
|
private byte[] fam;
|
||||||
|
@ -282,7 +289,7 @@ public class PrefixTreeSeeker implements EncodedSeeker {
|
||||||
private int valOffset;
|
private int valOffset;
|
||||||
private int valLength;
|
private int valLength;
|
||||||
private byte[] tag;
|
private byte[] tag;
|
||||||
private int tagLength;
|
private int tagsLength;
|
||||||
private long ts;
|
private long ts;
|
||||||
private long seqId;
|
private long seqId;
|
||||||
private byte type;
|
private byte type;
|
||||||
|
@ -302,7 +309,7 @@ public class PrefixTreeSeeker implements EncodedSeeker {
|
||||||
this.qualLength = qualLength;
|
this.qualLength = qualLength;
|
||||||
this.tag = new byte[tagLength];
|
this.tag = new byte[tagLength];
|
||||||
System.arraycopy(tag, tagOffset, this.tag, 0, tagLength);
|
System.arraycopy(tag, tagOffset, this.tag, 0, tagLength);
|
||||||
this.tagLength = tagLength;
|
this.tagsLength = tagLength;
|
||||||
this.val = val;
|
this.val = val;
|
||||||
this.valLength = valLength;
|
this.valLength = valLength;
|
||||||
this.valOffset = valOffset;
|
this.valOffset = valOffset;
|
||||||
|
@ -409,7 +416,7 @@ public class PrefixTreeSeeker implements EncodedSeeker {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTagsLength() {
|
public int getTagsLength() {
|
||||||
return this.tagLength;
|
return this.tagsLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -438,7 +445,18 @@ public class PrefixTreeSeeker implements EncodedSeeker {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue