@@ -95,15 +95,15 @@ public void testNonPartition() throws Exception {
9595 }
9696 BatchOperationResult batchOperationResult = batchOperation .execute ();
9797 // test get all partitions
98- List <Partition > partitions = client .getPartition (table_name );
98+ List <Partition > partitions = client .getPartition (table_name , false );
9999 Assert .assertEquals (1 , partitions .size ());
100100 for (Partition partition : partitions ) {
101101 System .out .println (partition .toString ());
102102 }
103103 Long lastPartId = -1L ;
104104 for (int i = 0 ; i < rowCnt ; i ++) {
105105 Object [] curRow = values [i ];
106- Partition partition = client .getPartition (table_name , row (colVal ("c1" , curRow [0 ])));
106+ Partition partition = client .getPartition (table_name , row (colVal ("c1" , curRow [0 ])), false );
107107 if (lastPartId == -1L ) {
108108 lastPartId = partition .getPartitionId ();
109109 } else {
@@ -133,7 +133,7 @@ PRIMARY KEY(`K`, `Q`, `T`)
133133 public void testOneLevelKeyPartition () throws Exception {
134134 String table_name = "testKey" ;
135135 BatchOperation batchOperation = client .batchOperation (table_name );
136- client .setRunningMode (ObTableClient .RunningMode .HBASE );
136+ // client.setRunningMode(ObTableClient.RunningMode.HBASE);
137137 Object values [][] = { { "K_val1" , "Q_val1" , 1L , "V_val1" },
138138 { "K_val2" , "Q_val2" , 101L , "V_val2" }, { "K_val3" , "Q_val3" , 501L , "V_val3" },
139139 { "K_val4" , "Q_val4" , 1001L , "V_val4" }, { "K_val5" , "Q_val5" , 5001L , "V_val5" },
@@ -152,17 +152,17 @@ public void testOneLevelKeyPartition() throws Exception {
152152 }
153153 BatchOperationResult batchOperationResult = batchOperation .execute ();
154154 // test get all partitions
155- List <Partition > partitions = client .getPartition (table_name );
155+ List <Partition > partitions = client .getPartition (table_name , false );
156156 Assert .assertEquals (15 , partitions .size ());
157157 for (Partition partition : partitions ) {
158158 System .out .println (partition .toString ());
159159 }
160160
161161 // test get the partition with only partition key with only partition key
162162 Partition first_partition = client .getPartition (table_name ,
163- row (colVal ("K" , "K_val1" ), colVal ("Q" , "Q_val1" ), colVal ("T" , 1L )));
163+ row (colVal ("K" , "K_val1" ), colVal ("Q" , "Q_val1" ), colVal ("T" , 1L )), false );
164164 Partition part_key_partition = client .getPartition (table_name ,
165- row (colVal ("K" , "K_val1" )));
165+ row (colVal ("K" , "K_val1" )), false );
166166 Assert .assertEquals (first_partition .getPartitionId (),
167167 part_key_partition .getPartitionId ());
168168 } catch (Exception e ) {
@@ -180,22 +180,23 @@ public void testOneLevelKeyPartition() throws Exception {
180180 }
181181
182182 /*
183- * CREATE TABLE IF NOT EXISTS `testHash` (
184- `K` int ,
183+ * CREATE TABLE IF NOT EXISTS `testHash`(
184+ `K` bigint ,
185185 `Q` varbinary(256),
186186 `T` bigint,
187187 `V` varbinary(1024),
188+ INDEX i1(`K`, `V`) local,
188189 PRIMARY KEY(`K`, `Q`, `T`)
189- ) partition by hash(K ) partitions 15 ;
190+ ) partition by hash(`K` ) partitions 16 ;
190191 * */
191192 @ Test
192193 public void testOneLevelHashPartition () throws Exception {
193194 String table_name = "testHash" ;
194195 BatchOperation batchOperation = client .batchOperation (table_name );
195- client .setRunningMode (ObTableClient .RunningMode .HBASE );
196- Object values [][] = { { 1 , "Q_val1" , 1L , "V_val1" }, { 10 , "Q_val2" , 101L , "V_val2" },
197- { 501 , "Q_val3" , 501L , "V_val3" }, { 1001 , "Q_val4" , 1001L , "V_val4" },
198- { 5001 , "Q_val5" , 5001L , "V_val5" }, { 10001 , "Q_val6" , 10001L , "V_val6" }, };
196+ // client.setRunningMode(ObTableClient.RunningMode.HBASE);
197+ Object values [][] = { { 1L , "Q_val1" , 1L , "V_val1" }, { 10L , "Q_val2" , 101L , "V_val2" },
198+ { 501L , "Q_val3" , 501L , "V_val3" }, { 1001L , "Q_val4" , 1001L , "V_val4" },
199+ { 5001L , "Q_val5" , 5001L , "V_val5" }, { 10001L , "Q_val6" , 10001L , "V_val6" }, };
199200 int rowCnt = values .length ;
200201
201202 try {
@@ -210,16 +211,16 @@ public void testOneLevelHashPartition() throws Exception {
210211 }
211212 BatchOperationResult batchOperationResult = batchOperation .execute ();
212213 // test get all partitions
213- List <Partition > partitions = client .getPartition (table_name );
214- Assert .assertEquals (15 , partitions .size ());
214+ List <Partition > partitions = client .getPartition (table_name , false );
215+ Assert .assertEquals (16 , partitions .size ());
215216 for (Partition partition : partitions ) {
216217 System .out .println (partition .toString ());
217218 }
218219
219220 // test get the partition with only partition key with only partition key
220221 Partition first_partition = client .getPartition (table_name ,
221- row (colVal ("K" , 1 ), colVal ("Q" , "Q_val1" ), colVal ("T" , 1L )));
222- Partition part_key_partition = client .getPartition (table_name , row (colVal ("K" , 1 )));
222+ row (colVal ("K" , 1 ), colVal ("Q" , "Q_val1" ), colVal ("T" , 1L )), false );
223+ Partition part_key_partition = client .getPartition (table_name , row (colVal ("K" , 1 )), false );
223224 Assert .assertEquals (first_partition .getPartitionId (),
224225 part_key_partition .getPartitionId ());
225226 } catch (Exception e ) {
@@ -236,72 +237,6 @@ public void testOneLevelHashPartition() throws Exception {
236237 }
237238 }
238239
239- /*
240- * CREATE TABLE IF NOT EXISTS `testSubStrKey` (
241- `K` varbinary(1024),
242- `Q` varbinary(256),
243- `T` bigint,
244- `V` varbinary(1024),
245- K_PREFIX varbinary(1024) generated always as (substring(`K`, 1, 4)),
246- PRIMARY KEY(`K`, `Q`, `T`)
247- ) partition by key(K_PREFIX) partitions 15;
248- * */
249- @ Test
250- public void testOneLevelSubStrKeyPartition () throws Exception {
251- String table_name = "testSubStrKey" ;
252- // BatchOperation batchOperation = client.batchOperation(TABLE_NAME);
253- client .addRowKeyElement (table_name , new String [] { "K" , "Q" , "T" });
254- Object values [][] = { { "K_val1" , "Q_val1" , 1L , "V_val1" },
255- { "K_val2" , "Q_val2" , 101L , "V_val2" }, { "K_val3" , "Q_val3" , 501L , "V_val3" },
256- { "K_val4" , "Q_val4" , 1001L , "V_val4" }, { "K_val5" , "Q_val5" , 5001L , "V_val5" },
257- { "K_val6" , "Q_val6" , 10001L , "V_val6" }, };
258- int rowCnt = values .length ;
259-
260- try {
261- // batch insert
262- // for (int i = 0; i < rowCnt; i++) {
263- // Object[] curRow = values[i];
264- // InsertOrUpdate insertOrUpdate = new InsertOrUpdate();
265- // insertOrUpdate.setRowKey(row(colVal("c1", curRow[0]), colVal("c2", curRow[1])));
266- // insertOrUpdate.addMutateRow(row(colVal("c3", curRow[2]), colVal("c4", curRow[3])));
267- // batchOperation.addOperation(insertOrUpdate);
268- // }
269- // BatchOperationResult batchOperationResult = batchOperation.execute();
270- // MutationResult res = client.insert(table_name)
271- // .setRowKey(row(colVal("K", "K_val1"), colVal("Q", "Q_val1".getBytes()), colVal("T", 1L)))
272- // .addMutateRow(row(colVal("V", "V_val1".getBytes()))).execute();
273- // Assert.assertEquals(1, res.getAffectedRows());
274- // test get all partitions
275- List <Partition > partitions = client .getPartition (table_name );
276- Assert .assertEquals (15 , partitions .size ());
277-
278- // Map<Long, Partition> partIdMap = new HashMap<>();
279- // for (Partition partition : partitions) {
280- // partIdMap.put(partition.getPartitionId(), partition);
281- // }
282- //
283- // // test get the first partition
284- // Partition first_partition = client.getPartition(TABLE_NAME, row(colVal("c1", 1L), colVal("c2", "c2_val")));
285- // Assert.assertEquals(partitions.get(0).getPartitionId(), first_partition.getPartitionId());
286- // // test get the second partition
287- // Partition sec_partition = client.getPartition(TABLE_NAME, row(colVal("c1", 401L), colVal("c2", "c2_val")));
288- // Assert.assertEquals(partitions.get(1).getPartitionId(), sec_partition.getPartitionId());
289- // // test get the partition with only partition key
290- // Partition partition1 = client.getPartition(TABLE_NAME, row(colVal("c1", 1L)));
291- // Assert.assertEquals(first_partition.getPartitionId(), partition1.getPartitionId());
292- } catch (Exception e ) {
293- e .printStackTrace ();
294- Assert .assertTrue (false );
295- } finally {
296- // for (int j = 0; j < rowCnt; j++) {
297- // Delete delete = client.delete(TABLE_NAME);
298- // delete.setRowKey(row(colVal("K", values[j][0]), colVal("Q", values[j][1]), colVal("T", values[j][2])));
299- // MutationResult res = delete.execute();
300- // Assert.assertEquals(1, res.getAffectedRows());
301- // }
302- }
303- }
304-
305240 /*
306241 * CREATE TABLE IF NOT EXISTS `testRange` (
307242 `c1` int NOT NULL,
@@ -333,24 +268,24 @@ public void testOneLevelRangePartition() throws Exception {
333268 }
334269 BatchOperationResult batchOperationResult = batchOperation .execute ();
335270 // test get all partitions
336- List <Partition > partitions = client .getPartition (table_name );
271+ List <Partition > partitions = client .getPartition (table_name , false );
337272 Assert .assertEquals (3 , partitions .size ());
338273 for (Partition partition : partitions ) {
339274 System .out .println (partition .toString ());
340275 }
341276
342277 // test get the first partition
343278 Partition first_partition = client .getPartition (table_name ,
344- row (colVal ("c1" , 1L ), colVal ("c2" , "c2_val" )));
279+ row (colVal ("c1" , 1L ), colVal ("c2" , "c2_val" )), false );
345280 Assert .assertEquals (partitions .get (0 ).getPartitionId (),
346281 first_partition .getPartitionId ());
347282 // test get the second partition
348283 Partition sec_partition = client .getPartition (table_name ,
349- row (colVal ("c1" , 401L ), colVal ("c2" , "c2_val" )));
284+ row (colVal ("c1" , 401L ), colVal ("c2" , "c2_val" )), false );
350285 Assert .assertEquals (partitions .get (1 ).getPartitionId (), sec_partition .getPartitionId ());
351286 // test get the same partition with the first partition key
352287 Partition partition1 = client .getPartition (table_name ,
353- row (colVal ("c1" , 101L ), colVal ("c2" , "c2_val" )));
288+ row (colVal ("c1" , 101L ), colVal ("c2" , "c2_val" )), false );
354289 Assert .assertEquals (first_partition .getPartitionId (), partition1 .getPartitionId ());
355290 } catch (Exception e ) {
356291 e .printStackTrace ();
@@ -401,7 +336,7 @@ public void testTwoLevelKeyPartition() throws Exception {
401336 Partition partition = client .getPartition (
402337 testTable ,
403338 row (colVal ("c0" , c0 ), colVal ("c1" , c1 ), colVal ("c2" , c2 ), colVal ("c3" , c3 ),
404- colVal ("c4" , c4 ), colVal ("c5" , c5 )));
339+ colVal ("c4" , c4 ), colVal ("c5" , c5 )), false );
405340 Assert .assertNotNull (partition );
406341 System .out .println (partition .toString ());
407342 // test scan range with partition
@@ -467,7 +402,7 @@ public void testTwoLevelRangePartition() throws Exception {
467402 statement .execute ("insert into " + testTable + "(c1, c2, c3, c4, c5) values (" + c1
468403 + "," + c2 + ",'" + c3 + "','" + c4 + "'," + "'value')" );
469404 Partition partition = client .getPartition (testTable ,
470- row (colVal ("c1" , c1 ), colVal ("c2" , c2 ), colVal ("c3" , c3 ), colVal ("c4" , c4 )));
405+ row (colVal ("c1" , c1 ), colVal ("c2" , c2 ), colVal ("c3" , c3 ), colVal ("c4" , c4 )), false );
471406 Assert .assertNotNull (partition );
472407 System .out .println (partition .toString ());
473408 // test scan range with partition
@@ -494,7 +429,7 @@ public void testConcurrentGetPartition() throws Exception {
494429 executorService .submit (() -> {
495430 try {
496431 String table_name = table_names [random .nextInt (table_names .length )];
497- List <Partition > partitions = client .getPartition (table_name );
432+ List <Partition > partitions = client .getPartition (table_name , false );
498433 if (table_name .equalsIgnoreCase ("testHash" )) {
499434 Assert .assertEquals (15 , partitions .size ());
500435 for (Partition partition : partitions ) {
0 commit comments