OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChunkMetadata.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, 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 #ifndef CHUNKMETADATA_H
18 #define CHUNKMETADATA_H
19 
20 #include <cstddef>
21 #include "../Shared/sqltypes.h"
22 
23 #include "Shared/Logger.h"
24 
25 struct ChunkStats {
28  bool has_nulls;
29 };
30 
31 struct ChunkMetadata {
33  size_t numBytes;
34  size_t numElements;
36 
37  template <typename T>
38  void fillChunkStats(const T min, const T max, const bool has_nulls) {
39  chunkStats.has_nulls = has_nulls;
40  switch (sqlType.get_type()) {
41  case kBOOLEAN: {
44  break;
45  }
46  case kTINYINT: {
49  break;
50  }
51  case kSMALLINT: {
54  break;
55  }
56  case kINT: {
57  chunkStats.min.intval = min;
58  chunkStats.max.intval = max;
59  break;
60  }
61  case kBIGINT:
62  case kNUMERIC:
63  case kDECIMAL: {
64  chunkStats.min.bigintval = min;
65  chunkStats.max.bigintval = max;
66  break;
67  }
68  case kTIME:
69  case kTIMESTAMP:
70  case kDATE: {
71  chunkStats.min.bigintval = min;
72  chunkStats.max.bigintval = max;
73  break;
74  }
75  case kFLOAT: {
76  chunkStats.min.floatval = min;
77  chunkStats.max.floatval = max;
78  break;
79  }
80  case kDOUBLE: {
81  chunkStats.min.doubleval = min;
82  chunkStats.max.doubleval = max;
83  break;
84  }
85  case kVARCHAR:
86  case kCHAR:
87  case kTEXT:
89  chunkStats.min.intval = min;
90  chunkStats.max.intval = max;
91  }
92  break;
93  default: {
94  break;
95  }
96  }
97  }
98 
99  void fillChunkStats(const Datum min, const Datum max, const bool has_nulls) {
100  chunkStats.has_nulls = has_nulls;
101  chunkStats.min = min;
102  chunkStats.max = max;
103  }
104 
105  bool operator==(const ChunkMetadata& that) const {
106  return sqlType == that.sqlType && numBytes == that.numBytes &&
107  numElements == that.numElements &&
111  }
112 };
113 
114 #endif // CHUNKMETADATA_H
int8_t tinyintval
Definition: sqltypes.h:126
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:334
void fillChunkStats(const T min, const T max, const bool has_nulls)
Definition: ChunkMetadata.h:38
bool has_nulls
Definition: ChunkMetadata.h:28
int32_t intval
Definition: sqltypes.h:128
ChunkStats chunkStats
Definition: ChunkMetadata.h:35
void fillChunkStats(const Datum min, const Datum max, const bool has_nulls)
Definition: ChunkMetadata.h:99
float floatval
Definition: sqltypes.h:130
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
Definition: Datum.cpp:153
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
int64_t bigintval
Definition: sqltypes.h:129
int16_t smallintval
Definition: sqltypes.h:127
Definition: sqltypes.h:55
Definition: sqltypes.h:56
Definition: sqltypes.h:44
Definition: sqltypes.h:48
SQLTypeInfo sqlType
Definition: ChunkMetadata.h:32
bool operator==(const ChunkMetadata &that) const
double doubleval
Definition: sqltypes.h:131
size_t numElements
Definition: ChunkMetadata.h:34