1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.hadoop.hbase;
18
19 import static org.junit.Assert.assertTrue;
20
21 import org.apache.hadoop.hbase.testclassification.SmallTests;
22 import org.apache.hadoop.hbase.util.Bytes;
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 @Category(SmallTests.class)
27 public class TestTagRewriteCell {
28
29 @Test
30 public void testHeapSize() {
31 Cell originalCell = CellUtil.createCell(Bytes.toBytes("row"), Bytes.toBytes("value"));
32 final int fakeTagArrayLength = 10;
33 TagRewriteCell trCell = new TagRewriteCell(originalCell, new byte[fakeTagArrayLength]);
34
35
36 long trCellHeapSize = trCell.heapSize();
37
38
39
40
41 TagRewriteCell trCell2 = new TagRewriteCell(trCell, new byte[fakeTagArrayLength]);
42
43 assertTrue("TagRewriteCell containing a TagRewriteCell's heapsize should be larger than a " +
44 "single TagRewriteCell's heapsize", trCellHeapSize < trCell2.heapSize());
45 assertTrue("TagRewriteCell should have had nulled out tags array", trCell.heapSize() <
46 trCellHeapSize);
47 }
48 }