OmniSciDB  72c90bc290
 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 {
45  return {ptr_, len_};
46  }
47 #endif
48 };
49 
50 static_assert(sizeof(char) == sizeof(int8_t));
51 static_assert(std::is_standard_layout<StringView>::value);
52 static_assert(std::is_trivial<StringView>::value);
53 
54 struct VarlenDatum {
55  size_t length;
56  int8_t* pointer;
57  bool is_null;
58 
59  DEVICE VarlenDatum() : length(0), pointer(nullptr), is_null(true) {}
60  DEVICE virtual ~VarlenDatum() {}
61 
62  VarlenDatum(const size_t l, int8_t* p, const bool n)
63  : length(l), pointer(p), is_null(n) {}
64 };
65 
66 static_assert(!std::is_standard_layout<VarlenDatum>::value);
67 static_assert(!std::is_trivial<VarlenDatum>::value);
68 
69 union Datum {
70  int8_t boolval;
71  int8_t tinyintval;
72  int16_t smallintval;
73  int32_t intval;
74  int64_t bigintval;
75  float floatval;
76  double doubleval;
78 #ifndef __CUDACC__
79  std::string* stringval; // string value
80 #endif
81 };
int8_t tinyintval
Definition: Datum.h:71
DEVICE VarlenDatum()
Definition: Datum.h:59
bool is_null
Definition: Datum.h:57
int8_t boolval
Definition: Datum.h:70
VarlenDatum * arrayval
Definition: Datum.h:77
uint64_t len_
Definition: Datum.h:41
int32_t intval
Definition: Datum.h:73
int8_t * pointer
Definition: Datum.h:56
#define DEVICE
float floatval
Definition: Datum.h:75
VarlenDatum(const size_t l, int8_t *p, const bool n)
Definition: Datum.h:62
int64_t bigintval
Definition: Datum.h:74
int16_t smallintval
Definition: Datum.h:72
std::string_view stringView() const
Definition: Datum.h:44
bool g_enable_smem_group_by true
std::string * stringval
Definition: Datum.h:79
virtual DEVICE ~VarlenDatum()
Definition: Datum.h:60
constexpr double n
Definition: Utm.h:38
char const * ptr_
Definition: Datum.h:40
Definition: Datum.h:69
double doubleval
Definition: Datum.h:76
size_t length
Definition: Datum.h:55