Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HBaseColumn.java
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.catalog;
16 
17 import com.cloudera.impala.thrift.TColumn;
18 
19 // Describes an HBase column mapped to a Hive column (as described in the metastore).
20 // this.name describes the column name in Hive.
21 // This class adds the HBase columnFamily and columnQualifier,
22 // so we can read the column from HBase directly.
23 public class HBaseColumn extends Column implements Comparable<HBaseColumn> {
24  private final String columnFamily_;
25  private final String columnQualifier_;
26  private final boolean binaryEncoded_;
27 
28  public HBaseColumn(String name, String columnFamily, String columnQualifier,
29  boolean binaryEncoded, Type type, String comment, int position) {
30  super(name, type, comment, position);
31  columnFamily_ = columnFamily;
32  columnQualifier_ = columnQualifier;
33  binaryEncoded_ = binaryEncoded;
34  }
35 
36  public String getColumnFamily() { return columnFamily_; }
37  public String getColumnQualifier() { return columnQualifier_; }
38  public boolean isBinaryEncoded() { return binaryEncoded_; }
39 
40  @Override
41  // We order the HBase columns in the matadata based on columnFamily,columnQualifier,
42  // to more easily map slots from HBase's Result.raw() to target slots in the backend.
43  public int compareTo(HBaseColumn o) {
44  int familyCmp = columnFamily_.compareTo(o.columnFamily_);
45  if (familyCmp != 0) {
46  return familyCmp;
47  }
48  int qualifierCmp = columnQualifier_.compareTo(o.columnQualifier_);
49  return qualifierCmp;
50  }
51 
52  @Override
53  public TColumn toThrift() {
54  TColumn colDesc = new TColumn(name_, type_.toThrift());
55  if (comment_ != null) colDesc.setComment(comment_);
56  colDesc.setCol_stats(getStats().toThrift());
57  colDesc.setPosition(position_);
58  colDesc.setIs_hbase_column(true);
59  colDesc.setColumn_family(columnFamily_);
60  colDesc.setColumn_qualifier(columnQualifier_);
61  colDesc.setIs_binary(binaryEncoded_);
62  return colDesc;
63  }
64 }
HBaseColumn(String name, String columnFamily, String columnQualifier, boolean binaryEncoded, Type type, String comment, int position)
string name
Definition: cpu-info.cc:50