Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MapType.java
Go to the documentation of this file.
1 package com.cloudera.impala.catalog;
2 
3 import com.cloudera.impala.thrift.TColumnType;
4 import com.cloudera.impala.thrift.TTypeNode;
5 import com.cloudera.impala.thrift.TTypeNodeType;
6 import com.google.common.base.Preconditions;
7 
11 public class MapType extends Type {
12  private final Type keyType_;
13  private final Type valueType_;
14 
15  public MapType(Type keyType, Type valueType) {
16  Preconditions.checkNotNull(keyType);
17  Preconditions.checkNotNull(valueType);
18  keyType_ = keyType;
19  valueType_ = valueType;
20  }
21 
22  public Type getKeyType() { return keyType_; }
23  public Type getValueType() { return valueType_; }
24 
25  @Override
26  public String toSql() {
27  return String.format("MAP<%s,%s>", keyType_.toSql(), valueType_.toSql());
28  }
29 
30  @Override
31  public void toThrift(TColumnType container) {
32  TTypeNode node = new TTypeNode();
33  container.types.add(node);
34  Preconditions.checkNotNull(keyType_);
35  Preconditions.checkNotNull(valueType_);
36  node.setType(TTypeNodeType.MAP);
37  keyType_.toThrift(container);
38  valueType_.toThrift(container);
39  }
40 }
void toThrift(TColumnType container)
Definition: MapType.java:31
MapType(Type keyType, Type valueType)
Definition: MapType.java:15