Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
anyval-util.cc
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
#include "
exprs/anyval-util.h
"
16
#include "
codegen/llvm-codegen.h
"
17
18
#include "
common/object-pool.h
"
19
20
#include "
common/names.h
"
21
22
using namespace
impala_udf;
23
24
namespace
impala {
25
26
AnyVal
*
CreateAnyVal
(
ObjectPool
*
pool
,
const
ColumnType
& type) {
27
return
pool->
Add
(
CreateAnyVal
(type));
28
}
29
30
AnyVal
*
CreateAnyVal
(
const
ColumnType
& type) {
31
switch
(type.
type
) {
32
case
TYPE_NULL
:
return
new
AnyVal
;
33
case
TYPE_BOOLEAN
:
return
new
BooleanVal
;
34
case
TYPE_TINYINT
:
return
new
TinyIntVal
;
35
case
TYPE_SMALLINT
:
return
new
SmallIntVal
;
36
case
TYPE_INT
:
return
new
IntVal
;
37
case
TYPE_BIGINT
:
return
new
BigIntVal
;
38
case
TYPE_FLOAT
:
return
new
FloatVal
;
39
case
TYPE_DOUBLE
:
return
new
DoubleVal
;
40
case
TYPE_STRING
:
41
case
TYPE_VARCHAR
:
42
case
TYPE_CHAR
:
43
return
new
StringVal
;
44
case
TYPE_TIMESTAMP
:
return
new
TimestampVal
;
45
case
TYPE_DECIMAL
:
return
new
DecimalVal
;
46
default
:
47
DCHECK(
false
) <<
"Unsupported type: "
<< type;
48
return
NULL;
49
}
50
}
51
52
FunctionContext::TypeDesc
AnyValUtil::ColumnTypeToTypeDesc(
const
ColumnType
& type) {
53
FunctionContext::TypeDesc
out;
54
switch
(type.
type
) {
55
case
TYPE_BOOLEAN
:
56
out.
type
=
FunctionContext::TYPE_BOOLEAN
;
57
break
;
58
case
TYPE_TINYINT
:
59
out.
type
=
FunctionContext::TYPE_TINYINT
;
60
break
;
61
case
TYPE_SMALLINT
:
62
out.
type
=
FunctionContext::TYPE_SMALLINT
;
63
break
;
64
case
TYPE_INT
:
65
out.
type
=
FunctionContext::TYPE_INT
;
66
break
;
67
case
TYPE_BIGINT
:
68
out.
type
=
FunctionContext::TYPE_BIGINT
;
69
break
;
70
case
TYPE_FLOAT
:
71
out.
type
=
FunctionContext::TYPE_FLOAT
;
72
break
;
73
case
TYPE_DOUBLE
:
74
out.
type
=
FunctionContext::TYPE_DOUBLE
;
75
break
;
76
case
TYPE_TIMESTAMP
:
77
out.
type
=
FunctionContext::TYPE_TIMESTAMP
;
78
break
;
79
case
TYPE_VARCHAR
:
80
out.
type
=
FunctionContext::TYPE_VARCHAR
;
81
out.
len
= type.
len
;
82
break
;
83
case
TYPE_STRING
:
84
out.
type
=
FunctionContext::TYPE_STRING
;
85
break
;
86
case
TYPE_CHAR
:
87
out.
type
=
FunctionContext::TYPE_FIXED_BUFFER
;
88
out.
len
= type.
len
;
89
break
;
90
case
TYPE_DECIMAL
:
91
out.
type
=
FunctionContext::TYPE_DECIMAL
;
92
out.
precision
= type.
precision
;
93
out.
scale
= type.
scale
;
94
break
;
95
default
:
96
DCHECK(
false
) <<
"Unknown type: "
<< type;
97
}
98
return
out;
99
}
100
101
ColumnType
AnyValUtil::TypeDescToColumnType(
const
FunctionContext::TypeDesc
& type) {
102
switch
(type.
type
) {
103
case
FunctionContext::TYPE_BOOLEAN
:
return
ColumnType
(
TYPE_BOOLEAN
);
104
case
FunctionContext::TYPE_TINYINT
:
return
ColumnType
(
TYPE_TINYINT
);
105
case
FunctionContext::TYPE_SMALLINT
:
return
ColumnType
(
TYPE_SMALLINT
);
106
case
FunctionContext::TYPE_INT
:
return
ColumnType
(
TYPE_INT
);
107
case
FunctionContext::TYPE_BIGINT
:
return
ColumnType
(
TYPE_BIGINT
);
108
case
FunctionContext::TYPE_FLOAT
:
return
ColumnType
(
TYPE_FLOAT
);
109
case
FunctionContext::TYPE_DOUBLE
:
return
ColumnType
(
TYPE_DOUBLE
);
110
case
FunctionContext::TYPE_TIMESTAMP
:
return
ColumnType
(
TYPE_TIMESTAMP
);
111
case
FunctionContext::TYPE_STRING
:
return
ColumnType
(
TYPE_STRING
);
112
case
FunctionContext::TYPE_DECIMAL
:
113
return
ColumnType::CreateDecimalType(type.
precision
, type.
scale
);
114
case
FunctionContext::TYPE_FIXED_BUFFER
:
115
return
ColumnType::CreateCharType(type.
len
);
116
case
FunctionContext::TYPE_VARCHAR
:
117
return
ColumnType::CreateVarcharType(type.
len
);
118
default
:
119
DCHECK(
false
) <<
"Unknown type: "
<< type.
type
;
120
return
ColumnType
(
INVALID_TYPE
);
121
}
122
}
123
124
}
impala_udf::FunctionContext::TypeDesc::precision
int precision
Only valid if type == TYPE_DECIMAL.
Definition:
udf.h:75
impala::TYPE_DOUBLE
Definition:
types.h:36
impala::TYPE_CHAR
Definition:
types.h:47
impala::TYPE_VARCHAR
Definition:
types.h:48
impala_udf::AnyVal
Definition:
udf.h:358
impala_udf::FunctionContext::TYPE_TINYINT
Definition:
udf.h:58
impala_udf::FunctionContext::TYPE_VARCHAR
Definition:
udf.h:68
impala::ColumnType::precision
int precision
Only set if type == TYPE_DECIMAL.
Definition:
types.h:68
impala_udf::DoubleVal
Definition:
udf.h:475
impala_udf::FunctionContext::TYPE_FIXED_BUFFER
Definition:
udf.h:66
impala::ColumnType::scale
int scale
Definition:
types.h:68
impala::INVALID_TYPE
Definition:
types.h:28
impala::ObjectPool
Definition:
object-pool.h:30
impala_udf::FunctionContext::TYPE_DECIMAL
Definition:
udf.h:67
llvm-codegen.h
impala_udf::TimestampVal
This object has a compatible storage format with boost::ptime.
Definition:
udf.h:495
impala_udf::FunctionContext::TYPE_DOUBLE
Definition:
udf.h:63
impala::TYPE_TIMESTAMP
Definition:
types.h:37
object-pool.h
impala_udf::FunctionContext::TypeDesc::type
Type type
Definition:
udf.h:72
impala_udf::TinyIntVal
Definition:
udf.h:382
impala_udf::FloatVal
Definition:
udf.h:458
impala::TYPE_INT
Definition:
types.h:33
impala::ColumnType::type
PrimitiveType type
Definition:
types.h:60
impala_udf::FunctionContext::TypeDesc
Definition:
udf.h:71
anyval-util.h
impala_udf::SmallIntVal
Definition:
udf.h:401
impala::TYPE_SMALLINT
Definition:
types.h:32
impala_udf::FunctionContext::TypeDesc::scale
int scale
Definition:
udf.h:76
pool
ObjectPool pool
Definition:
expr-benchmark.cc:89
impala_udf::DecimalVal
Definition:
udf.h:556
impala_udf::StringVal
Definition:
udf.h:521
impala::ColumnType::len
int len
Only set if type == TYPE_CHAR or type == TYPE_VARCHAR.
Definition:
types.h:62
impala_udf::IntVal
Definition:
udf.h:420
impala::TYPE_BOOLEAN
Definition:
types.h:30
impala::TYPE_BIGINT
Definition:
types.h:34
impala::TYPE_NULL
Definition:
types.h:29
impala_udf::FunctionContext::TYPE_BIGINT
Definition:
udf.h:61
impala_udf::BigIntVal
Definition:
udf.h:439
impala::ColumnType
Definition:
types.h:59
names.h
impala::ObjectPool::Add
T * Add(T *t)
Definition:
object-pool.h:42
impala_udf::FunctionContext::TypeDesc::len
int len
Only valid if type == TYPE_FIXED_BUFFER || type == TYPE_VARCHAR.
Definition:
udf.h:79
impala_udf::FunctionContext::TYPE_TIMESTAMP
Definition:
udf.h:64
impala::TYPE_STRING
Definition:
types.h:38
impala::CreateAnyVal
AnyVal * CreateAnyVal(const ColumnType &type)
Creates the corresponding AnyVal subclass for type. The object is owned by the caller.
Definition:
anyval-util.cc:30
impala_udf::FunctionContext::TYPE_SMALLINT
Definition:
udf.h:59
impala_udf::FunctionContext::TYPE_STRING
Definition:
udf.h:65
impala::TYPE_TINYINT
Definition:
types.h:31
impala::TYPE_FLOAT
Definition:
types.h:35
impala_udf::FunctionContext::TYPE_INT
Definition:
udf.h:60
impala_udf::FunctionContext::TYPE_FLOAT
Definition:
udf.h:62
impala_udf::FunctionContext::TYPE_BOOLEAN
Definition:
udf.h:57
impala::TYPE_DECIMAL
Definition:
types.h:42
impala_udf::BooleanVal
Definition:
udf.h:363
be
src
exprs
anyval-util.cc
Generated on Thu May 7 2015 16:10:36 for Impala by
1.8.6