OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Datum.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2022 HEAVY.AI, Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
24 #pragma once
25 
26 #include "funcannotations.h"
27 
28 #ifndef __CUDACC__
29 #include <string_view>
30 #endif
31 
32 #ifndef __CUDACC__
33 static_assert(!std::is_trivial<std::string_view>::value);
34 #endif
35 
36 // Since std::string_view is not a Trivial class, we use StringView instead,
37 // which is both Trivial and has Standard-layout (aka POD).
38 // This is like std::string_view but can be used in the context of cuda and llvm.
39 struct StringView {
40  char const* ptr_;
41  uint64_t len_;
42 
43 #ifndef __CUDACC__
44  std::string_view stringView() const { return {ptr_, len_}; }
45 #endif
46 };
47 
48 static_assert(sizeof(char) == sizeof(int8_t));
49 static_assert(std::is_standard_layout<StringView>::value);
50 static_assert(std::is_trivial<StringView>::value);
51 
52 struct VarlenDatum {
53  size_t length;
54  int8_t* pointer;
55  bool is_null;
56 
57  DEVICE VarlenDatum() : length(0), pointer(nullptr), is_null(true) {}
58  DEVICE virtual ~VarlenDatum() {}
59 
60  VarlenDatum(const size_t l, int8_t* p, const bool n)
61  : length(l), pointer(p), is_null(n) {}
62 };
63 
64 static_assert(!std::is_standard_layout<VarlenDatum>::value);
65 static_assert(!std::is_trivial<VarlenDatum>::value);
66 
67 union Datum {
68  int8_t boolval;
69  int8_t tinyintval;
70  int16_t smallintval;
71  int32_t intval;
72  int64_t bigintval;
73  float floatval;
74  double doubleval;
76 #ifndef __CUDACC__
77  std::string* stringval; // string value
78 #endif
79 };
int8_t tinyintval
Definition: Datum.h:69
DEVICE VarlenDatum()
Definition: Datum.h:57
bool is_null
Definition: Datum.h:55
int8_t boolval
Definition: Datum.h:68
VarlenDatum * arrayval
Definition: Datum.h:75
uint64_t len_
Definition: Datum.h:41
int32_t intval
Definition: Datum.h:71
int8_t * pointer
Definition: Datum.h:54
#define DEVICE
float floatval
Definition: Datum.h:73
VarlenDatum(const size_t l, int8_t *p, const bool n)
Definition: Datum.h:60
int64_t bigintval
Definition: Datum.h:72
int16_t smallintval
Definition: Datum.h:70
std::string_view stringView() const
Definition: Datum.h:44
bool g_enable_smem_group_by true
std::string * stringval
Definition: Datum.h:77
virtual DEVICE ~VarlenDatum()
Definition: Datum.h:58
constexpr double n
Definition: Utm.h:38
char const * ptr_
Definition: Datum.h:40
Definition: Datum.h:67
double doubleval
Definition: Datum.h:74
size_t length
Definition: Datum.h:53