| 38 | const char* ColumnType::LLVM_CLASS_NAME = "struct.impala::ColumnType"; |
| 39 | |
| 40 | ColumnType::ColumnType(const std::vector<TTypeNode>& types, int* idx) |
| 41 | : len(-1), precision(-1), scale(-1), is_binary_(false) { |
| 42 | DCHECK_GE(*idx, 0); |
| 43 | DCHECK_LT(*idx, types.size()); |
| 44 | const TTypeNode& node = types[*idx]; |
| 45 | switch (node.type) { |
| 46 | case TTypeNodeType::SCALAR: { |
| 47 | DCHECK(node.__isset.scalar_type); |
| 48 | const TScalarType scalar_type = node.scalar_type; |
| 49 | type = ThriftToType(scalar_type.type); |
| 50 | if (type == TYPE_CHAR || type == TYPE_VARCHAR |
| 51 | || type == TYPE_FIXED_UDA_INTERMEDIATE) { |
| 52 | DCHECK(scalar_type.__isset.len); |
| 53 | len = scalar_type.len; |
| 54 | } else if (type == TYPE_STRING) { |
| 55 | is_binary_ = scalar_type.type == TPrimitiveType::BINARY; |
| 56 | } else if (type == TYPE_DECIMAL) { |
| 57 | DCHECK(scalar_type.__isset.precision); |
| 58 | DCHECK(scalar_type.__isset.scale); |
| 59 | precision = scalar_type.precision; |
| 60 | scale = scalar_type.scale; |
| 61 | } |
| 62 | break; |
| 63 | } |
| 64 | case TTypeNodeType::STRUCT: |
| 65 | type = TYPE_STRUCT; |
| 66 | for (int i = 0; i < node.struct_fields.size(); ++i) { |
| 67 | ++(*idx); |
| 68 | children.push_back(ColumnType(types, idx)); |
| 69 | field_names.push_back(node.struct_fields[i].name); |
| 70 | field_ids.push_back(node.struct_fields[i].field_id); |
| 71 | } |
| 72 | break; |
| 73 | case TTypeNodeType::ARRAY: |
| 74 | DCHECK(!node.__isset.scalar_type); |
| 75 | DCHECK_LT(*idx, types.size() - 1); |
| 76 | type = TYPE_ARRAY; |
| 77 | ++(*idx); |
| 78 | children.push_back(ColumnType(types, idx)); |
| 79 | break; |
| 80 | case TTypeNodeType::MAP: |
| 81 | DCHECK(!node.__isset.scalar_type); |
| 82 | DCHECK_LT(*idx, types.size() - 2); |
| 83 | type = TYPE_MAP; |
| 84 | ++(*idx); |
| 85 | children.push_back(ColumnType(types, idx)); |
| 86 | ++(*idx); |
| 87 | children.push_back(ColumnType(types, idx)); |
| 88 | break; |
| 89 | default: |
| 90 | DCHECK(false) << node.type; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | PrimitiveType ThriftToType(TPrimitiveType::type ttype) { |
| 95 | switch (ttype) { |
nothing calls this directly
no test coverage detected