@@ -109,21 +109,24 @@ PRIMARY KEY (`K`, `Q`, `T`)
109
109
110
110
@ Test
111
111
public void testBasic () throws Exception {
112
+ testBasic ("family1" );
113
+ }
114
+
115
+ private void testBasic (String family ) throws Exception {
112
116
String key = "putKey" ;
113
117
String column1 = "putColumn1" ;
114
118
String column2 = "putColumn2" ;
115
119
String value = "value" ;
116
- String family = "family1" ;
117
120
long timestamp = System .currentTimeMillis ();
118
121
Delete delete = new Delete (key .getBytes ());
119
122
delete .deleteFamily (family .getBytes ());
120
123
hTable .delete (delete );
121
124
122
125
Put put = new Put (toBytes (key ));
123
- put .add ("family1" .getBytes (), column1 .getBytes (), timestamp , toBytes (value ));
126
+ put .add (family .getBytes (), column1 .getBytes (), timestamp , toBytes (value ));
124
127
hTable .put (put );
125
128
Get get = new Get (toBytes (key ));
126
- get .addColumn ("family1" .getBytes (), toBytes (column1 ));
129
+ get .addColumn (family .getBytes (), toBytes (column1 ));
127
130
Result r = hTable .get (get );
128
131
Assert .assertEquals (1 , r .raw ().length );
129
132
@@ -137,10 +140,10 @@ public void testBasic() throws Exception {
137
140
}
138
141
139
142
put = new Put (toBytes (key ));
140
- put .add ("family1" .getBytes (), column1 .getBytes (), timestamp + 1 , toBytes (value ));
143
+ put .add (family .getBytes (), column1 .getBytes (), timestamp + 1 , toBytes (value ));
141
144
hTable .put (put );
142
145
get = new Get (toBytes (key ));
143
- get .addColumn ("family1" .getBytes (), toBytes (column1 ));
146
+ get .addColumn (family .getBytes (), toBytes (column1 ));
144
147
get .setMaxVersions (2 );
145
148
r = hTable .get (get );
146
149
Assert .assertEquals (2 , r .raw ().length );
@@ -165,14 +168,14 @@ public void testBasic() throws Exception {
165
168
try {
166
169
for (int j = 0 ; j < 10 ; j ++) {
167
170
put = new Put ((key + "_" + j ).getBytes ());
168
- put .add ("family1" .getBytes (), column1 .getBytes (), toBytes (value ));
169
- put .add ("family1" .getBytes (), column2 .getBytes (), toBytes (value ));
171
+ put .add (family .getBytes (), column1 .getBytes (), toBytes (value ));
172
+ put .add (family .getBytes (), column2 .getBytes (), toBytes (value ));
170
173
hTable .put (put );
171
174
}
172
175
173
176
Scan scan = new Scan ();
174
- scan .addColumn ("family1" .getBytes (), column1 .getBytes ());
175
- scan .addColumn ("family1" .getBytes (), column2 .getBytes ());
177
+ scan .addColumn (family .getBytes (), column1 .getBytes ());
178
+ scan .addColumn (family .getBytes (), column2 .getBytes ());
176
179
scan .setStartRow (toBytes (key + "_" + 0 ));
177
180
scan .setStopRow (toBytes (key + "_" + 9 ));
178
181
scan .setMaxVersions (9 );
@@ -2171,4 +2174,10 @@ public void testIncrementConcurrency() throws Exception {
2171
2174
result = hTable .get (get );
2172
2175
assertEquals (101 , result .raw ().length );
2173
2176
}
2177
+
2178
+ // Test operation in hbase table with local index
2179
+ @ Test
2180
+ public void testHtableWithIndex () throws Exception {
2181
+ testBasic ("family_with_local_index" );
2182
+ }
2174
2183
}
0 commit comments