View Javadoc

1   /*
2    * Copyright (c) 2010.  The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.hadoop.hbase.hbql.mapping;
22  
23  import org.apache.expreval.expr.ArgumentListTypeSignature;
24  import org.apache.expreval.expr.ExpressionProperty;
25  import org.apache.expreval.expr.PropertyType;
26  import org.apache.expreval.expr.node.BooleanValue;
27  import org.apache.expreval.expr.node.GenericValue;
28  import org.apache.expreval.expr.node.IntegerValue;
29  
30  public class FamilyProperty extends ExpressionProperty {
31  
32      public static enum Type implements PropertyType {
33  
34          MAX_VERSIONS(new ArgumentListTypeSignature(IntegerValue.class), "MAX_VERSIONS"),
35          MAP_FILE_INDEX_INTERVAL(new ArgumentListTypeSignature(IntegerValue.class), "MAP_FILE_INDEX_INTERVAL"),
36          TTL(new ArgumentListTypeSignature(IntegerValue.class), "TTL"),
37          IN_MEMORY(new ArgumentListTypeSignature(BooleanValue.class), "IN_MEMORY"),
38          BLOCK_SIZE(new ArgumentListTypeSignature(IntegerValue.class), "BLOCK_SIZE"),
39          BLOCK_CACHE_ENABLED(new ArgumentListTypeSignature(BooleanValue.class), "BLOCK_CACHE_ENABLED"),
40          BLOOM_FILTER(new ArgumentListTypeSignature(BooleanValue.class), "BLOOM_FILTER"),
41          COMPRESSION_TYPE(new ArgumentListTypeSignature(), "COMPRESSION_TYPE");
42  
43          private final ArgumentListTypeSignature typeSignature;
44          private final String description;
45  
46          Type(final ArgumentListTypeSignature typeSignature, final String description) {
47              this.typeSignature = typeSignature;
48              this.description = description;
49          }
50  
51          public ArgumentListTypeSignature getTypeSignature() {
52              return this.typeSignature;
53          }
54  
55          public String getDescription() {
56              return this.description;
57          }
58      }
59  
60      public FamilyProperty(final String text, final GenericValue... arg0) {
61          super(FamilyProperty.Type.valueOf(text.toUpperCase()), arg0);
62      }
63  
64      public FamilyProperty(final Type type, final GenericValue... exprs) {
65          super(type, exprs);
66      }
67  
68      public Type getEnumType() {
69          return (Type)this.getPropertyType();
70      }
71  
72      public String asString() {
73          return this.getPropertyType().getDescription() + ": " + this.getGenericValue(0).asString();
74      }
75  }