View Javadoc

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
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
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.
17   */
18  package org.apache.hadoop.hbase.codec.prefixtree.row.data;
19  
20  import java.io.ByteArrayOutputStream;
21  import java.io.DataOutputStream;
22  import java.io.IOException;
23  import java.util.List;
24  
25  import org.apache.hadoop.hbase.KeyValue;
26  import org.apache.hadoop.hbase.codec.prefixtree.row.BaseTestRowData;
27  import org.apache.hadoop.hbase.util.Bytes;
28  
29  import com.google.common.collect.Lists;
30  
31  public class TestRowDataSearchWithPrefix extends BaseTestRowData {
32  
33    static byte[] cf = Bytes.toBytes("cf");
34  
35    static byte[] cq = Bytes.toBytes("cq");
36  
37    static byte[] v = Bytes.toBytes("v");
38  
39    static List<KeyValue> d = Lists.newArrayList();
40  
41    static long ts = 55L;
42  
43    static byte[] createRowKey(int keyPart1, int keyPart2) {
44      ByteArrayOutputStream bos = new ByteArrayOutputStream(16);
45      DataOutputStream dos = new DataOutputStream(bos);
46      try {
47        dos.writeInt(keyPart1);
48        dos.writeInt(keyPart2);
49      } catch (IOException e) {
50        // should not happen
51        throw new RuntimeException(e);
52      }
53  
54      return bos.toByteArray();
55    }
56  
57    static {
58      d.add(new KeyValue(createRowKey(1, 12345), cf, cq, ts, v));
59      d.add(new KeyValue(createRowKey(12345, 0x01000000), cf, cq, ts, v));
60      d.add(new KeyValue(createRowKey(12345, 0x01010000), cf, cq, ts, v));
61      d.add(new KeyValue(createRowKey(12345, 0x02000000), cf, cq, ts, v));
62      d.add(new KeyValue(createRowKey(12345, 0x02020000), cf, cq, ts, v));
63      d.add(new KeyValue(createRowKey(12345, 0x03000000), cf, cq, ts, v));
64      d.add(new KeyValue(createRowKey(12345, 0x03030000), cf, cq, ts, v));
65      d.add(new KeyValue(createRowKey(12345, 0x04000000), cf, cq, ts, v));
66      d.add(new KeyValue(createRowKey(12345, 0x04040000), cf, cq, ts, v));
67    }
68  
69    @Override
70    public List<KeyValue> getInputs() {
71      return d;
72    }
73  
74  }