1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.mapreduce;
19
20 import java.io.IOException;
21 import java.util.List;
22
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.hbase.classification.InterfaceStability;
25 import org.apache.hadoop.conf.Configuration;
26 import org.apache.hadoop.hbase.Cell;
27 import org.apache.hadoop.hbase.KeyValue;
28 import org.apache.hadoop.hbase.Tag;
29 import org.apache.hadoop.util.ReflectionUtils;
30
31
32
33
34 @InterfaceAudience.Public
35 @InterfaceStability.Evolving
36 public class CellCreator {
37
38 @InterfaceStability.Unstable
39 public static final String VISIBILITY_EXP_RESOLVER_CLASS =
40 "hbase.mapreduce.visibility.expression.resolver.class";
41
42 private VisibilityExpressionResolver visExpResolver;
43
44 public CellCreator(Configuration conf) {
45 Class<? extends VisibilityExpressionResolver> clazz = conf.getClass(
46 VISIBILITY_EXP_RESOLVER_CLASS, DefaultVisibilityExpressionResolver.class,
47 VisibilityExpressionResolver.class);
48 this.visExpResolver = ReflectionUtils.newInstance(clazz, conf);
49 this.visExpResolver.init();
50 }
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength,
70 byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset,
71 int vlength) throws IOException {
72 return create(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, qlength,
73 timestamp, value, voffset, vlength, (List<Tag>)null);
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 @Deprecated
95 public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength,
96 byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset,
97 int vlength, String visExpression) throws IOException {
98 List<Tag> visTags = null;
99 if (visExpression != null) {
100 visTags = this.visExpResolver.createVisibilityExpTags(visExpression);
101 }
102 return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
103 qlength, timestamp, KeyValue.Type.Put, value, voffset, vlength, visTags);
104 }
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength,
125 byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset,
126 int vlength, List<Tag> tags) throws IOException {
127 return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
128 qlength, timestamp, KeyValue.Type.Put, value, voffset, vlength, tags);
129 }
130
131
132
133
134 @InterfaceStability.Unstable
135 public VisibilityExpressionResolver getVisibilityExpressionResolver() {
136 return this.visExpResolver;
137 }
138 }