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