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;
20  
21  import java.util.Collection;
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.row.data.TestRowDataComplexQualifiers;
27  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataDeeper;
28  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataDifferentTimestamps;
29  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataEmpty;
30  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataExerciseFInts;
31  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataNub;
32  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataNumberStrings;
33  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataQualifierByteOrdering;
34  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataRandomKeyValues;
35  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataRandomKeyValuesWithTags;
36  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataSearchWithPrefix;
37  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataSearcherRowMiss;
38  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataSimple;
39  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataSingleQualifier;
40  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataTrivial;
41  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataTrivialWithTags;
42  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataUrls;
43  import org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataUrlsExample;
44  import org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher;
45  
46  import com.google.common.collect.Lists;
47  
48  /*
49   * A master class for registering different implementations of TestRowData.
50   */
51  public interface TestRowData {
52  
53    List<KeyValue> getInputs();
54    List<Integer> getRowStartIndexes();
55  
56    void individualBlockMetaAssertions(PrefixTreeBlockMeta blockMeta);
57  
58    void individualSearcherAssertions(CellSearcher searcher);
59  
60    class InMemory {
61  
62      /*
63       * The following are different styles of data that the codec may encounter.  Having these small
64       * representations of the data helps pinpoint what is wrong if the encoder breaks.
65       */
66      public static Collection<TestRowData> getAll() {
67        List<TestRowData> all = Lists.newArrayList();
68        //simple
69        all.add(new TestRowDataEmpty());
70        all.add(new TestRowDataTrivial());
71        all.add(new TestRowDataTrivialWithTags());
72        all.add(new TestRowDataSimple());
73        all.add(new TestRowDataDeeper());
74  
75        //more specific
76        all.add(new TestRowDataSingleQualifier());
77  //      all.add(new TestRowDataMultiFamilies());//multiple families disabled in PrefixTreeEncoder
78        all.add(new TestRowDataNub());
79        all.add(new TestRowDataSearcherRowMiss());
80        all.add(new TestRowDataQualifierByteOrdering());
81        all.add(new TestRowDataComplexQualifiers());
82        all.add(new TestRowDataDifferentTimestamps());
83  
84        //larger data volumes (hard to debug)
85        all.add(new TestRowDataNumberStrings());
86        all.add(new TestRowDataUrls());
87        all.add(new TestRowDataUrlsExample());
88        all.add(new TestRowDataExerciseFInts());
89        all.add(new TestRowDataRandomKeyValues());
90        all.add(new TestRowDataRandomKeyValuesWithTags());
91        
92        //test data for HBase-12078
93        all.add(new TestRowDataSearchWithPrefix());
94        return all;
95      }
96  
97      public static Collection<Object[]> getAllAsObjectArray() {
98        List<Object[]> all = Lists.newArrayList();
99        for (TestRowData testRows : getAll()) {
100         all.add(new Object[] { testRows });
101       }
102       return all;
103     }
104   }
105 }