1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase;
19
20 import java.io.IOException;
21
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23 import org.apache.hadoop.hbase.io.HeapSize;
24 import org.apache.hadoop.hbase.util.ClassSize;
25
26
27
28
29
30
31 @InterfaceAudience.Private
32 public class TagRewriteCell implements Cell, SettableSequenceId, SettableTimestamp, HeapSize {
33
34 private Cell cell;
35 private byte[] tags;
36
37
38
39
40
41 public TagRewriteCell(Cell cell, byte[] tags) {
42 assert cell instanceof SettableSequenceId;
43 assert cell instanceof SettableTimestamp;
44 assert tags != null;
45 this.cell = cell;
46 this.tags = tags;
47
48 if (this.cell instanceof TagRewriteCell) {
49
50 ((TagRewriteCell) this.cell).tags = null;
51 }
52 }
53
54 @Override
55 public byte[] getRowArray() {
56 return cell.getRowArray();
57 }
58
59 @Override
60 public int getRowOffset() {
61 return cell.getRowOffset();
62 }
63
64 @Override
65 public short getRowLength() {
66 return cell.getRowLength();
67 }
68
69 @Override
70 public byte[] getFamilyArray() {
71 return cell.getFamilyArray();
72 }
73
74 @Override
75 public int getFamilyOffset() {
76 return cell.getFamilyOffset();
77 }
78
79 @Override
80 public byte getFamilyLength() {
81 return cell.getFamilyLength();
82 }
83
84 @Override
85 public byte[] getQualifierArray() {
86 return cell.getQualifierArray();
87 }
88
89 @Override
90 public int getQualifierOffset() {
91 return cell.getQualifierOffset();
92 }
93
94 @Override
95 public int getQualifierLength() {
96 return cell.getQualifierLength();
97 }
98
99 @Override
100 public long getTimestamp() {
101 return cell.getTimestamp();
102 }
103
104 @Override
105 public byte getTypeByte() {
106 return cell.getTypeByte();
107 }
108
109 @Override
110 public long getSequenceId() {
111 return cell.getSequenceId();
112 }
113
114 @Override
115 public byte[] getValueArray() {
116 return cell.getValueArray();
117 }
118
119 @Override
120 public int getValueOffset() {
121 return cell.getValueOffset();
122 }
123
124 @Override
125 public int getValueLength() {
126 return cell.getValueLength();
127 }
128
129 @Override
130 public byte[] getTagsArray() {
131 return this.tags;
132 }
133
134 @Override
135 public int getTagsOffset() {
136 return 0;
137 }
138
139 @Override
140 public int getTagsLength() {
141 if (null == this.tags) {
142
143 return 0;
144 }
145 return this.tags.length;
146 }
147
148 @Override
149 public long heapSize() {
150 long sum = CellUtil.estimatedHeapSizeOf(cell) - cell.getTagsLength();
151 sum += ClassSize.OBJECT;
152 sum += (2 * ClassSize.REFERENCE);
153 if (this.tags != null) {
154 sum += ClassSize.align(ClassSize.ARRAY);
155 sum += this.tags.length;
156 }
157 return sum;
158 }
159
160 @Override
161 public void setTimestamp(long ts) throws IOException {
162
163 CellUtil.setTimestamp(cell, ts);
164 }
165
166 @Override
167 public void setTimestamp(byte[] ts, int tsOffset) throws IOException {
168
169 CellUtil.setTimestamp(cell, ts, tsOffset);
170 }
171
172 @Override
173 public void setSequenceId(long seqId) throws IOException {
174
175 CellUtil.setSequenceId(cell, seqId);
176 }
177 }