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