1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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 }