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