1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.client;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.NavigableMap;
24 import java.util.UUID;
25
26 import org.apache.hadoop.hbase.classification.InterfaceAudience;
27 import org.apache.hadoop.hbase.classification.InterfaceStability;
28 import org.apache.hadoop.hbase.Cell;
29 import org.apache.hadoop.hbase.CellUtil;
30 import org.apache.hadoop.hbase.KeyValue;
31 import org.apache.hadoop.hbase.security.access.Permission;
32 import org.apache.hadoop.hbase.security.visibility.CellVisibility;
33 import org.apache.hadoop.hbase.util.Bytes;
34
35
36
37
38
39
40
41
42
43
44
45
46
47 @InterfaceAudience.Public
48 @InterfaceStability.Stable
49 public class Append extends Mutation {
50
51
52
53
54
55
56 public Append setReturnResults(boolean returnResults) {
57 setAttribute(RETURN_RESULTS, Bytes.toBytes(returnResults));
58 return this;
59 }
60
61
62
63
64 public boolean isReturnResults() {
65 byte[] v = getAttribute(RETURN_RESULTS);
66 return v == null ? true : Bytes.toBoolean(v);
67 }
68
69
70
71
72
73
74
75 public Append(byte[] row) {
76 this(row, 0, row.length);
77 }
78
79
80
81
82 public Append(Append a) {
83 this.row = a.getRow();
84 this.ts = a.getTimeStamp();
85 this.familyMap.putAll(a.getFamilyCellMap());
86 for (Map.Entry<String, byte[]> entry : a.getAttributesMap().entrySet()) {
87 this.setAttribute(entry.getKey(), entry.getValue());
88 }
89 }
90
91
92
93
94
95
96
97
98 public Append(final byte [] rowArray, final int rowOffset, final int rowLength) {
99 checkRow(rowArray, rowOffset, rowLength);
100 this.row = Bytes.copy(rowArray, rowOffset, rowLength);
101 }
102
103
104
105
106
107
108
109
110 public Append add(byte [] family, byte [] qualifier, byte [] value) {
111 KeyValue kv = new KeyValue(this.row, family, qualifier, this.ts, KeyValue.Type.Put, value);
112 return add(kv);
113 }
114
115
116
117
118
119
120 @SuppressWarnings("unchecked")
121 public Append add(final Cell cell) {
122
123 byte [] family = CellUtil.cloneFamily(cell);
124 List<Cell> list = this.familyMap.get(family);
125 if (list == null) {
126 list = new ArrayList<Cell>();
127 }
128
129 list.add(cell);
130 this.familyMap.put(family, list);
131 return this;
132 }
133
134 @Override
135 public Append setAttribute(String name, byte[] value) {
136 return (Append) super.setAttribute(name, value);
137 }
138
139 @Override
140 public Append setId(String id) {
141 return (Append) super.setId(id);
142 }
143
144 @Override
145 @Deprecated
146 public Append setWriteToWAL(boolean write) {
147 return (Append) super.setWriteToWAL(write);
148 }
149
150 @Override
151 public Append setDurability(Durability d) {
152 return (Append) super.setDurability(d);
153 }
154
155 @Override
156 public Append setFamilyCellMap(NavigableMap<byte[], List<Cell>> map) {
157 return (Append) super.setFamilyCellMap(map);
158 }
159
160 @Override
161 @Deprecated
162 public Append setFamilyMap(NavigableMap<byte[], List<KeyValue>> map) {
163 return (Append) super.setFamilyMap(map);
164 }
165
166 @Override
167 public Append setClusterIds(List<UUID> clusterIds) {
168 return (Append) super.setClusterIds(clusterIds);
169 }
170
171 @Override
172 public Append setCellVisibility(CellVisibility expression) {
173 return (Append) super.setCellVisibility(expression);
174 }
175
176 @Override
177 public Append setACL(String user, Permission perms) {
178 return (Append) super.setACL(user, perms);
179 }
180
181 @Override
182 public Append setACL(Map<String, Permission> perms) {
183 return (Append) super.setACL(perms);
184 }
185
186 @Override
187 public Append setTTL(long ttl) {
188 return (Append) super.setTTL(ttl);
189 }
190 }