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.PrefixTreeBlockMeta;
26  import org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeTestConstants;
27  import org.apache.hadoop.hbase.codec.prefixtree.row.BaseTestRowData;
28  import org.apache.hadoop.hbase.util.ByteRange;
29  import org.apache.hadoop.hbase.util.Bytes;
30  import org.apache.hadoop.hbase.util.SimpleByteRange;
31  import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
32  import org.junit.Assert;
33  
34  import com.google.common.collect.Lists;
35  
36  /*
37   * test different timestamps
38   *
39   * http://pastebin.com/7ks8kzJ2
40   * http://pastebin.com/MPn03nsK
41   */
42  public class TestRowDataExerciseFInts extends BaseTestRowData{
43  
44    static List<ByteRange> rows;
45  	static{
46  		List<String> rowStrings = new ArrayList<String>();
47          rowStrings.add("com.edsBlog/directoryAa/pageAaa");
48          rowStrings.add("com.edsBlog/directoryAa/pageBbb");
49          rowStrings.add("com.edsBlog/directoryAa/pageCcc");
50          rowStrings.add("com.edsBlog/directoryAa/pageDdd");
51          rowStrings.add("com.edsBlog/directoryBb/pageEee");
52          rowStrings.add("com.edsBlog/directoryBb/pageFff");
53          rowStrings.add("com.edsBlog/directoryBb/pageGgg");
54          rowStrings.add("com.edsBlog/directoryBb/pageHhh");
55          rowStrings.add("com.isabellasBlog/directoryAa/pageAaa");
56          rowStrings.add("com.isabellasBlog/directoryAa/pageBbb");
57          rowStrings.add("com.isabellasBlog/directoryAa/pageCcc");
58          rowStrings.add("com.isabellasBlog/directoryAa/pageDdd");
59          rowStrings.add("com.isabellasBlog/directoryBb/pageEee");
60          rowStrings.add("com.isabellasBlog/directoryBb/pageFff");
61          rowStrings.add("com.isabellasBlog/directoryBb/pageGgg");
62          rowStrings.add("com.isabellasBlog/directoryBb/pageHhh");
63          ByteRangeTreeSet ba = new ByteRangeTreeSet();
64          for(String row : rowStrings){
65          	ba.add(new SimpleByteRange(Bytes.toBytes(row)));
66          }
67          rows = ba.compile().getSortedRanges();
68  	}
69  
70  	static List<String> cols = Lists.newArrayList();
71  	static{
72  		cols.add("Chrome");
73  		cols.add("Chromeb");
74  		cols.add("Firefox");
75  		cols.add("InternetExplorer");
76  		cols.add("Opera");
77  		cols.add("Safari");
78  		cols.add("Z1stBrowserWithHuuuuuuuuuuuugeQualifier");
79  		cols.add("Z2ndBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
80  		cols.add("Z3rdBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
81  		cols.add("Z4thBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
82  		cols.add("Z5thBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
83  		cols.add("Z6thBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
84  		cols.add("Z7thBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
85  		cols.add("Z8thBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
86  		cols.add("Z9thBrowserWithEvenBiggerQualifierMoreMoreMoreMoreMore");
87  	}
88  
89    static long ts = 1234567890;
90  
91    static int MAX_VALUE = 50;
92  
93    static List<KeyValue> kvs = Lists.newArrayList();
94    static {
95      for (ByteRange row : rows) {
96        for (String col : cols) {
97          KeyValue kv = new KeyValue(row.deepCopyToNewArray(), PrefixTreeTestConstants.TEST_CF,
98              Bytes.toBytes(col), ts, KeyValue.Type.Put, Bytes.toBytes("VALUE"));
99          kvs.add(kv);
100       }
101     }
102   }
103 
104   @Override
105   public List<KeyValue> getInputs() {
106     return kvs;
107   }
108 
109   @Override
110   public void individualBlockMetaAssertions(PrefixTreeBlockMeta blockMeta) {
111     Assert.assertTrue(blockMeta.getNextNodeOffsetWidth() > 1);
112     Assert.assertTrue(blockMeta.getQualifierOffsetWidth() > 1);
113   }
114 
115 }