HBASE-3921 Allow adding arbitrary blobs to Put; fix TestHeapSize

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1128905 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2011-05-29 17:02:11 +00:00
parent 433d9c8a30
commit 92845b63c4
1 changed files with 8 additions and 1 deletions

View File

@ -62,7 +62,7 @@ public class Put implements HeapSize, Writable, Row, Comparable<Row> {
private Map<String, byte[]> attributes; private Map<String, byte[]> attributes;
private static final long OVERHEAD = ClassSize.align( private static final long OVERHEAD = ClassSize.align(
ClassSize.OBJECT + ClassSize.REFERENCE + ClassSize.OBJECT + 2 * ClassSize.REFERENCE +
2 * Bytes.SIZEOF_LONG + Bytes.SIZEOF_BOOLEAN + 2 * Bytes.SIZEOF_LONG + Bytes.SIZEOF_BOOLEAN +
ClassSize.REFERENCE + ClassSize.TREEMAP); ClassSize.REFERENCE + ClassSize.TREEMAP);
@ -527,6 +527,13 @@ public class Put implements HeapSize, Writable, Row, Comparable<Row> {
heapsize += kv.heapSize(); heapsize += kv.heapSize();
} }
} }
if (attributes != null) {
heapsize += ClassSize.align(this.attributes.size() * ClassSize.MAP_ENTRY);
for(Map.Entry<byte [], List<KeyValue>> entry : this.familyMap.entrySet()) {
heapsize += ClassSize.align(ClassSize.STRING + entry.getKey().length);
heapsize += ClassSize.align(ClassSize.ARRAY + entry.getValue().size());
}
}
return ClassSize.align((int)heapsize); return ClassSize.align((int)heapsize);
} }