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 public static final String VISIBILITY_EXP_RESOLVER_CLASS =
39 "hbase.mapreduce.visibility.expression.resolver.class";
40
41 private VisibilityExpressionResolver visExpResolver;
42
43 public CellCreator(Configuration conf) {
44 Class<? extends VisibilityExpressionResolver> clazz = conf.getClass(
45 VISIBILITY_EXP_RESOLVER_CLASS, DefaultVisibilityExpressionResolver.class,
46 VisibilityExpressionResolver.class);
47 this.visExpResolver = ReflectionUtils.newInstance(clazz, conf);
48 this.visExpResolver.init();
49 }
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength,
69 byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset,
70 int vlength) throws IOException {
71 return create(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, qlength,
72 timestamp, value, voffset, vlength, (List<Tag>)null);
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 @Deprecated
94 public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength,
95 byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset,
96 int vlength, String visExpression) throws IOException {
97 List<Tag> visTags = null;
98 if (visExpression != null) {
99 visTags = this.visExpResolver.createVisibilityExpTags(visExpression);
100 }
101 return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
102 qlength, timestamp, KeyValue.Type.Put, value, voffset, vlength, visTags);
103 }
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength,
124 byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset,
125 int vlength, List<Tag> tags) throws IOException {
126 return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset,
127 qlength, timestamp, KeyValue.Type.Put, value, voffset, vlength, tags);
128 }
129
130
131
132
133 public VisibilityExpressionResolver getVisibilityExpressionResolver() {
134 return this.visExpResolver;
135 }
136 }