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 testNumOfSplits("-1", 50);
117 testNumOfSplits("100", 1);
118 }
119
120
121
122
123
124
125
126
127 @Test
128 public void testGetSplitsPoint() throws IOException, InterruptedException,
129 ClassNotFoundException {
130
131 byte[] start1 = { 'a', 'a', 'a', 'b', 'c', 'd', 'e', 'f' };
132 byte[] end1 = { 'a', 'a', 'a', 'f', 'f' };
133 byte[] splitPoint1 = { 'a', 'a', 'a', 'd' };
134 testGetSplitKey(start1, end1, splitPoint1, true);
135
136
137 byte[] start2 = { '1', '1', '1', '0', '0', '0' };
138 byte[] end2 = { '1', '1', '2', '5', '7', '9', '0' };
139 byte[] splitPoint2 = { '1', '1', '1', 'b' };
140 testGetSplitKey(start2, end2, splitPoint2, true);
141
142
143 byte[] start3 = { 'a', 'a', 'a', 'a', 'a', 'a' };
144 byte[] end3 = { 'a', 'a', 'b' };
145 byte[] splitPoint3 = { 'a', 'a', 'a', 'p' };
146 testGetSplitKey(start3, end3, splitPoint3, true);
147
148
149 byte[] start4 = { 'a', 'a', 'a' };
150 byte[] end4 = { 'a', 'a', 'a', 'z' };
151 byte[] splitPoint4 = { 'a', 'a', 'a', 'M' };
152 testGetSplitKey(start4, end4, splitPoint4, true);
153
154
155 byte[] start5 = { 'a', 'a', 'a' };
156 byte[] end5 = { 'a', 'a', 'b', 'a' };
157 byte[] splitPoint5 = { 'a', 'a', 'a', 'p' };
158 testGetSplitKey(start5, end5, splitPoint5, true);
159
160
161 byte[] start6 = {};
162 byte[] end6 = { 'h', 'h', 'h', 'q', 'q', 'q', 'w', 'w' };
163 byte[] splitPoint6 = { 'h' };
164 testGetSplitKey(start6, end6, splitPoint6, true);
165
166
167
168 byte[] start7 = { 'f', 'f', 'f', 'f', 'a', 'a', 'a' };
169 byte[] end7 = {};
170 byte[] splitPointText7 = { 'f', '~', '~', '~', '~', '~', '~' };
171 byte[] splitPointBinary7 = { 'f', 127, 127, 127, 127, 127, 127 };
172 testGetSplitKey(start7, end7, splitPointText7, true);
173 testGetSplitKey(start7, end7, splitPointBinary7, false);
174
175
176
177 byte[] start8 = {};
178 byte[] end8 = {};
179 byte[] splitPointText8 = { 'O' };
180 byte[] splitPointBinary8 = { 0 };
181 testGetSplitKey(start8, end8, splitPointText8, true);
182 testGetSplitKey(start8, end8, splitPointBinary8, false);
183
184
185 byte[] start9 = { 13, -19, 126, 127 };
186 byte[] end9 = { 13, -19, 127, 0 };
187 byte[] splitPoint9 = { 13, -19, 127, -64 };
188 testGetSplitKey(start9, end9, splitPoint9, false);
189 }
190 }