OmniSciDB  c07336695a
DatumFetchers.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "sqltypes.h"
20 
21 namespace DatumFetcher {
22 
23 template <typename T>
24 T getDatumVal(const Datum& d);
25 
26 template <>
27 int8_t getDatumVal(const Datum& d) {
28  return d.tinyintval;
29 }
30 
31 template <>
32 int16_t getDatumVal(const Datum& d) {
33  return d.smallintval;
34 }
35 
36 template <>
37 int32_t getDatumVal(const Datum& d) {
38  return d.intval;
39 }
40 
41 template <>
42 int64_t getDatumVal(const Datum& d) {
43  return d.bigintval;
44 }
45 
46 template <>
47 uint8_t getDatumVal(const Datum& d) {
48  return d.tinyintval;
49 }
50 
51 template <>
52 uint16_t getDatumVal(const Datum& d) {
53  return d.smallintval;
54 }
55 
56 template <>
57 float getDatumVal(const Datum& d) {
58  return d.floatval;
59 }
60 
61 template <>
62 double getDatumVal(const Datum& d) {
63  return d.doubleval;
64 }
65 
66 } // namespace DatumFetcher
int8_t tinyintval
Definition: sqltypes.h:123
void d(const SQLTypes expected_type, const std::string &str)
Definition: ImportTest.cpp:268
Constants for Builtin SQL Types supported by MapD.
int32_t intval
Definition: sqltypes.h:125
T getDatumVal(const Datum &d)
Definition: DatumFetchers.h:27
float floatval
Definition: sqltypes.h:127
int64_t bigintval
Definition: sqltypes.h:126
int16_t smallintval
Definition: sqltypes.h:124
double doubleval
Definition: sqltypes.h:128