HBASE-22002 Remove the deprecated methods in Admin interface
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / client / TestIntraRowPagination.java
blob32da9bdfc87a79dec4c03d5ac02c6e7707215561
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.apache.hadoop.hbase.Cell;
23 import org.apache.hadoop.hbase.HBaseClassTestRule;
24 import org.apache.hadoop.hbase.HBaseTestingUtility;
25 import org.apache.hadoop.hbase.HColumnDescriptor;
26 import org.apache.hadoop.hbase.HRegionInfo;
27 import org.apache.hadoop.hbase.HTableDescriptor;
28 import org.apache.hadoop.hbase.HTestConst;
29 import org.apache.hadoop.hbase.KeyValue;
30 import org.apache.hadoop.hbase.TableName;
31 import org.apache.hadoop.hbase.regionserver.HRegion;
32 import org.apache.hadoop.hbase.regionserver.RegionScanner;
33 import org.apache.hadoop.hbase.testclassification.ClientTests;
34 import org.apache.hadoop.hbase.testclassification.SmallTests;
35 import org.junit.ClassRule;
36 import org.junit.Test;
37 import org.junit.experimental.categories.Category;
39 /**
40 * Test scan/get offset and limit settings within one row through HRegion API.
42 @Category({SmallTests.class, ClientTests.class})
43 public class TestIntraRowPagination {
45 @ClassRule
46 public static final HBaseClassTestRule CLASS_RULE =
47 HBaseClassTestRule.forClass(TestIntraRowPagination.class);
49 private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
51 /**
52 * Test from client side for scan with maxResultPerCF set
54 * @throws Exception
56 @Test
57 public void testScanLimitAndOffset() throws Exception {
58 //byte [] TABLE = HTestConst.DEFAULT_TABLE_BYTES;
59 byte [][] ROWS = HTestConst.makeNAscii(HTestConst.DEFAULT_ROW_BYTES, 2);
60 byte [][] FAMILIES = HTestConst.makeNAscii(HTestConst.DEFAULT_CF_BYTES, 3);
61 byte [][] QUALIFIERS = HTestConst.makeNAscii(HTestConst.DEFAULT_QUALIFIER_BYTES, 10);
63 HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(HTestConst.DEFAULT_TABLE_BYTES));
64 HRegionInfo info = new HRegionInfo(HTestConst.DEFAULT_TABLE, null, null, false);
65 for (byte[] family : FAMILIES) {
66 HColumnDescriptor hcd = new HColumnDescriptor(family);
67 htd.addFamily(hcd);
69 HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(),
70 TEST_UTIL.getConfiguration(), htd);
71 try {
72 Put put;
73 Scan scan;
74 Result result;
75 boolean toLog = true;
77 List<Cell> kvListExp = new ArrayList<>();
79 int storeOffset = 1;
80 int storeLimit = 3;
81 for (int r = 0; r < ROWS.length; r++) {
82 put = new Put(ROWS[r]);
83 for (int c = 0; c < FAMILIES.length; c++) {
84 for (int q = 0; q < QUALIFIERS.length; q++) {
85 KeyValue kv = new KeyValue(ROWS[r], FAMILIES[c], QUALIFIERS[q], 1,
86 HTestConst.DEFAULT_VALUE_BYTES);
87 put.add(kv);
88 if (storeOffset <= q && q < storeOffset + storeLimit) {
89 kvListExp.add(kv);
93 region.put(put);
96 scan = new Scan();
97 scan.setRowOffsetPerColumnFamily(storeOffset);
98 scan.setMaxResultsPerColumnFamily(storeLimit);
99 RegionScanner scanner = region.getScanner(scan);
100 List<Cell> kvListScan = new ArrayList<>();
101 List<Cell> results = new ArrayList<>();
102 while (scanner.next(results) || !results.isEmpty()) {
103 kvListScan.addAll(results);
104 results.clear();
106 result = Result.create(kvListScan);
107 TestScannersFromClientSide.verifyResult(result, kvListExp, toLog,
108 "Testing scan with storeOffset and storeLimit");
109 } finally {
110 HBaseTestingUtility.closeRegionAndWAL(region);