1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.mapreduce;
20
21 import java.io.IOException;
22 import java.util.List;
23
24 import org.apache.hadoop.hbase.HRegionLocation;
25 import org.apache.hadoop.hbase.client.HTable;
26 import org.apache.hadoop.hbase.testclassification.LargeTests;
27 import org.junit.Test;
28 import org.junit.experimental.categories.Category;
29
30
31
32
33
34 @Category(LargeTests.class)
35 public class TestTableInputFormatScan1 extends TestTableInputFormatScanBase {
36
37
38
39
40
41
42
43
44 @Test
45 public void testScanEmptyToEmpty()
46 throws IOException, InterruptedException, ClassNotFoundException {
47 testScan(null, null, null);
48 }
49
50
51
52
53
54
55
56
57 @Test
58 public void testScanEmptyToAPP()
59 throws IOException, InterruptedException, ClassNotFoundException {
60 testScan(null, "app", "apo");
61 }
62
63
64
65
66
67
68
69
70 @Test
71 public void testScanEmptyToBBA()
72 throws IOException, InterruptedException, ClassNotFoundException {
73 testScan(null, "bba", "baz");
74 }
75
76
77
78
79
80
81
82
83 @Test
84 public void testScanEmptyToBBB()
85 throws IOException, InterruptedException, ClassNotFoundException {
86 testScan(null, "bbb", "bba");
87 }
88
89
90
91
92
93
94
95
96 @Test
97 public void testScanEmptyToOPP()
98 throws IOException, InterruptedException, ClassNotFoundException {
99 testScan(null, "opp", "opo");
100 }
101
102
103
104
105
106
107
108
109
110
111
112
113
114 @Test
115 public void testGetSplits() throws IOException, InterruptedException, ClassNotFoundException {
116 HTable table = new HTable(TEST_UTIL.getConfiguration(), TABLE_NAME);
117 List<HRegionLocation> locs = table.getRegionLocator().getAllRegionLocations();
118
119 testNumOfSplits("-1", locs.size()*2);
120 table.close();
121 testNumOfSplits("100", 1);
122 }
123
124
125
126
127
128
129
130
131 @Test
132 public void testGetSplitsPoint() throws IOException, InterruptedException,
133 ClassNotFoundException {
134
135 byte[] start1 = { 'a', 'a', 'a', 'b', 'c', 'd', 'e', 'f' };
136 byte[] end1 = { 'a', 'a', 'a', 'f', 'f' };
137 byte[] splitPoint1 = { 'a', 'a', 'a', 'd' };
138 testGetSplitKey(start1, end1, splitPoint1, true);
139
140
141 byte[] start2 = { '1', '1', '1', '0', '0', '0' };
142 byte[] end2 = { '1', '1', '2', '5', '7', '9', '0' };
143 byte[] splitPoint2 = { '1', '1', '1', 'b' };
144 testGetSplitKey(start2, end2, splitPoint2, true);
145
146
147 byte[] start3 = { 'a', 'a', 'a', 'a', 'a', 'a' };
148 byte[] end3 = { 'a', 'a', 'b' };
149 byte[] splitPoint3 = { 'a', 'a', 'a', 'p' };
150 testGetSplitKey(start3, end3, splitPoint3, true);
151
152
153 byte[] start4 = { 'a', 'a', 'a' };
154 byte[] end4 = { 'a', 'a', 'a', 'z' };
155 byte[] splitPoint4 = { 'a', 'a', 'a', 'M' };
156 testGetSplitKey(start4, end4, splitPoint4, true);
157
158
159 byte[] start5 = { 'a', 'a', 'a' };
160 byte[] end5 = { 'a', 'a', 'b', 'a' };
161 byte[] splitPoint5 = { 'a', 'a', 'a', 'p' };
162 testGetSplitKey(start5, end5, splitPoint5, true);
163
164
165 byte[] start6 = {};
166 byte[] end6 = { 'h', 'h', 'h', 'q', 'q', 'q', 'w', 'w' };
167 byte[] splitPoint6 = { 'h' };
168 testGetSplitKey(start6, end6, splitPoint6, true);
169
170
171
172 byte[] start7 = { 'f', 'f', 'f', 'f', 'a', 'a', 'a' };
173 byte[] end7 = {};
174 byte[] splitPointText7 = { 'f', '~', '~', '~', '~', '~', '~' };
175 byte[] splitPointBinary7 = { 'f', 127, 127, 127, 127, 127, 127 };
176 testGetSplitKey(start7, end7, splitPointText7, true);
177 testGetSplitKey(start7, end7, splitPointBinary7, false);
178
179
180
181 byte[] start8 = {};
182 byte[] end8 = {};
183 byte[] splitPointText8 = { 'O' };
184 byte[] splitPointBinary8 = { 0 };
185 testGetSplitKey(start8, end8, splitPointText8, true);
186 testGetSplitKey(start8, end8, splitPointBinary8, false);
187
188
189 byte[] start9 = { 13, -19, 126, 127 };
190 byte[] end9 = { 13, -19, 127, 0 };
191 byte[] splitPoint9 = { 13, -19, 127, -64 };
192 testGetSplitKey(start9, end9, splitPoint9, false);
193 }
194 }