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  
19  package org.apache.hadoop.hbase.codec.prefixtree.row.data;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import org.apache.hadoop.hbase.KeyValue;
25  import org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeTestConstants;
26  import org.apache.hadoop.hbase.codec.prefixtree.row.BaseTestRowData;
27  import org.apache.hadoop.hbase.util.ByteRange;
28  import org.apache.hadoop.hbase.util.Bytes;
29  import org.apache.hadoop.hbase.util.SimpleByteRange;
30  import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
31  
32  import com.google.common.collect.Lists;
33  
34  /*
35   * test different timestamps
36   * 
37   * http://pastebin.com/7ks8kzJ2
38   * http://pastebin.com/MPn03nsK
39   */
40  public class TestRowDataUrls extends BaseTestRowData{
41  
42    static List<ByteRange> rows;
43  	static{
44      List<String> rowStrings = new ArrayList<String>();
45      rowStrings.add("com.edsBlog/directoryAa/pageAaa");
46      rowStrings.add("com.edsBlog/directoryAa/pageBbb");
47      rowStrings.add("com.edsBlog/directoryAa/pageCcc");
48      rowStrings.add("com.edsBlog/directoryAa/pageDdd");
49      rowStrings.add("com.edsBlog/directoryBb/pageEee");
50      rowStrings.add("com.edsBlog/directoryBb/pageFff");
51      rowStrings.add("com.edsBlog/directoryBb/pageGgg");
52      rowStrings.add("com.edsBlog/directoryBb/pageHhh");
53      rowStrings.add("com.isabellasBlog/directoryAa/pageAaa");
54      rowStrings.add("com.isabellasBlog/directoryAa/pageBbb");
55      rowStrings.add("com.isabellasBlog/directoryAa/pageCcc");
56      rowStrings.add("com.isabellasBlog/directoryAa/pageDdd");
57      rowStrings.add("com.isabellasBlog/directoryBb/pageEee");
58      rowStrings.add("com.isabellasBlog/directoryBb/pageFff");
59      rowStrings.add("com.isabellasBlog/directoryBb/pageGgg");
60      rowStrings.add("com.isabellasBlog/directoryBb/pageHhh");
61      ByteRangeTreeSet ba = new ByteRangeTreeSet();
62      for (String row : rowStrings) {
63        ba.add(new SimpleByteRange(Bytes.toBytes(row)));
64      }
65      rows = ba.compile().getSortedRanges();
66    }
67  
68    static List<String> cols = Lists.newArrayList();
69    static {
70      cols.add("Chrome");
71      cols.add("Chromeb");
72      cols.add("Firefox");
73      cols.add("InternetExplorer");
74      cols.add("Opera");
75      cols.add("Safari");
76    }
77  
78    static long ts = 1234567890;
79  
80    static int MAX_VALUE = 50;
81  
82    static List<KeyValue> kvs = Lists.newArrayList();
83    static {
84      for (ByteRange row : rows) {
85        for (String col : cols) {
86          KeyValue kv = new KeyValue(row.deepCopyToNewArray(), PrefixTreeTestConstants.TEST_CF,
87              Bytes.toBytes(col), ts, KeyValue.Type.Put, Bytes.toBytes("VALUE"));
88          kvs.add(kv);
89          // System.out.println("TestRows5:"+kv);
90        }
91      }
92    }
93  
94    @Override
95    public List<KeyValue> getInputs() {
96      return kvs;
97    }
98  
99  }