OmniSciDB  2e3a973ef4
foreign_storage::ArrayMetadataStats Class Reference

#include <ArrayMetadataStats.h>

+ Collaboration diagram for foreign_storage::ArrayMetadataStats:

Public Member Functions

 ArrayMetadataStats ()
 
void updateStats (const SQLTypeInfo &type_info, const Datum &min, const Datum &max)
 
template<typename T >
void updateStats (const SQLTypeInfo &type_info, const T &min, const T &max)
 
Datum getMin (const SQLTypeInfo &type_info) const
 
Datum getMax (const SQLTypeInfo &type_info) const
 

Private Member Functions

Datum getUninitializedMin (const SQLTypeInfo &type_info) const
 
Datum getUninitializedMax (const SQLTypeInfo &type_info) const
 
template<typename V , typename T >
void updateMin (V &current_min, const T &value)
 
template<typename V , typename T >
void updateMax (V &current_max, const T &value)
 

Private Attributes

bool is_min_initialized_
 
bool is_max_initialized_
 
Datum min_
 
Datum max_
 

Detailed Description

Definition at line 23 of file ArrayMetadataStats.h.

Constructor & Destructor Documentation

◆ ArrayMetadataStats()

foreign_storage::ArrayMetadataStats::ArrayMetadataStats ( )
inline

Member Function Documentation

◆ getMax()

Datum foreign_storage::ArrayMetadataStats::getMax ( const SQLTypeInfo type_info) const
inline

Definition at line 163 of file ArrayMetadataStats.h.

References getUninitializedMax(), is_max_initialized_, and max_.

Referenced by foreign_storage::ParquetDataWrapper::loadMetadataChunk().

163  {
164  if (is_max_initialized_) {
165  return max_;
166  }
167  return getUninitializedMax(type_info);
168  }
Datum getUninitializedMax(const SQLTypeInfo &type_info) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMin()

Datum foreign_storage::ArrayMetadataStats::getMin ( const SQLTypeInfo type_info) const
inline

Definition at line 156 of file ArrayMetadataStats.h.

References getUninitializedMin(), is_min_initialized_, and min_.

Referenced by foreign_storage::ParquetDataWrapper::loadMetadataChunk().

156  {
157  if (is_min_initialized_) {
158  return min_;
159  }
160  return getUninitializedMin(type_info);
161  }
Datum getUninitializedMin(const SQLTypeInfo &type_info) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUninitializedMax()

Datum foreign_storage::ArrayMetadataStats::getUninitializedMax ( const SQLTypeInfo type_info) const
inlineprivate

Definition at line 213 of file ArrayMetadataStats.h.

References Datum::bigintval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_type(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::tinyintval, run_benchmark_import::type, and UNREACHABLE.

Referenced by getMax().

213  {
214  Datum d;
215  auto type = type_info.get_type();
216  switch (type) {
217  case kSMALLINT:
218  d.smallintval = std::numeric_limits<int16_t>::lowest();
219  break;
220  case kBOOLEAN:
221  case kTINYINT:
222  d.tinyintval = std::numeric_limits<int8_t>::lowest();
223  break;
224  case kFLOAT:
225  d.floatval = std::numeric_limits<float>::lowest();
226  break;
227  case kDOUBLE:
228  d.doubleval = std::numeric_limits<double>::lowest();
229  break;
230  case kTEXT:
231  case kVARCHAR:
232  case kCHAR:
233  case kINT:
234  d.intval = std::numeric_limits<int32_t>::lowest();
235  break;
236  case kTIME:
237  case kTIMESTAMP:
238  case kDATE:
239  case kBIGINT:
240  case kNUMERIC:
241  case kDECIMAL:
242  d.bigintval = std::numeric_limits<int64_t>::lowest();
243  break;
244  case kPOINT:
245  case kLINESTRING:
246  case kPOLYGON:
247  case kMULTIPOLYGON:
248  UNREACHABLE();
249  default:
250  UNREACHABLE();
251  }
252  return d;
253  }
int8_t tinyintval
Definition: sqltypes.h:135
Definition: sqltypes.h:51
#define UNREACHABLE()
Definition: Logger.h:241
int32_t intval
Definition: sqltypes.h:137
float floatval
Definition: sqltypes.h:139
int64_t bigintval
Definition: sqltypes.h:138
int16_t smallintval
Definition: sqltypes.h:136
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:43
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
Definition: sqltypes.h:47
double doubleval
Definition: sqltypes.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUninitializedMin()

Datum foreign_storage::ArrayMetadataStats::getUninitializedMin ( const SQLTypeInfo type_info) const
inlineprivate

Definition at line 171 of file ArrayMetadataStats.h.

References Datum::bigintval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_type(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, Datum::smallintval, Datum::tinyintval, run_benchmark_import::type, and UNREACHABLE.

Referenced by getMin().

171  {
172  Datum d;
173  auto type = type_info.get_type();
174  switch (type) {
175  case kSMALLINT:
176  d.smallintval = std::numeric_limits<int16_t>::max();
177  break;
178  case kBOOLEAN:
179  case kTINYINT:
180  d.tinyintval = std::numeric_limits<int8_t>::max();
181  break;
182  case kFLOAT:
183  d.floatval = std::numeric_limits<float>::max();
184  break;
185  case kDOUBLE:
186  d.doubleval = std::numeric_limits<double>::max();
187  break;
188  case kTEXT:
189  case kVARCHAR:
190  case kCHAR:
191  case kINT:
192  d.intval = std::numeric_limits<int32_t>::max();
193  break;
194  case kTIME:
195  case kTIMESTAMP:
196  case kDATE:
197  case kBIGINT:
198  case kNUMERIC:
199  case kDECIMAL:
200  d.bigintval = std::numeric_limits<int64_t>::max();
201  break;
202  case kPOINT:
203  case kLINESTRING:
204  case kPOLYGON:
205  case kMULTIPOLYGON:
206  UNREACHABLE();
207  default:
208  UNREACHABLE();
209  }
210  return d;
211  }
int8_t tinyintval
Definition: sqltypes.h:135
Definition: sqltypes.h:51
#define UNREACHABLE()
Definition: Logger.h:241
int32_t intval
Definition: sqltypes.h:137
float floatval
Definition: sqltypes.h:139
int64_t bigintval
Definition: sqltypes.h:138
int16_t smallintval
Definition: sqltypes.h:136
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:43
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
Definition: sqltypes.h:47
double doubleval
Definition: sqltypes.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateMax()

template<typename V , typename T >
void foreign_storage::ArrayMetadataStats::updateMax ( V &  current_max,
const T &  value 
)
inlineprivate

Definition at line 266 of file ArrayMetadataStats.h.

References is_max_initialized_.

Referenced by updateStats().

266  {
267  if (!is_max_initialized_) {
268  current_max = value;
269  } else {
270  current_max = std::max<V>(current_max, value);
271  }
272  is_max_initialized_ = true;
273  }
+ Here is the caller graph for this function:

◆ updateMin()

template<typename V , typename T >
void foreign_storage::ArrayMetadataStats::updateMin ( V &  current_min,
const T &  value 
)
inlineprivate

Definition at line 256 of file ArrayMetadataStats.h.

References is_min_initialized_.

Referenced by updateStats().

256  {
257  if (!is_min_initialized_) {
258  current_min = value;
259  } else {
260  current_min = std::min<V>(current_min, value);
261  }
262  is_min_initialized_ = true;
263  }
+ Here is the caller graph for this function:

◆ updateStats() [1/2]

void foreign_storage::ArrayMetadataStats::updateStats ( const SQLTypeInfo type_info,
const Datum min,
const Datum max 
)
inline

Definition at line 27 of file ArrayMetadataStats.h.

References Datum::bigintval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, max_, min_, Datum::smallintval, Datum::tinyintval, UNREACHABLE, updateMax(), and updateMin().

Referenced by foreign_storage::ParquetDataWrapper::loadMetadataChunk(), and foreign_storage::anonymous_namespace{LazyParquetImporter.cpp}::update_array_metadata_stats().

27  {
28  switch (type_info.get_type()) {
29  case kBOOLEAN: {
32  break;
33  }
34  case kTINYINT: {
37  break;
38  }
39  case kSMALLINT: {
42  break;
43  }
44  case kINT: {
47  break;
48  }
49  case kBIGINT:
50  case kNUMERIC:
51  case kDECIMAL: {
54  break;
55  }
56  case kTIME:
57  case kTIMESTAMP:
58  case kDATE: {
61  break;
62  }
63  case kFLOAT: {
66  break;
67  }
68  case kDOUBLE: {
71  break;
72  }
73  case kVARCHAR:
74  case kCHAR:
75  case kTEXT:
76  if (type_info.get_compression() == kENCODING_DICT) {
79  }
80  break;
81  case kPOINT:
82  case kLINESTRING:
83  case kPOLYGON:
84  case kMULTIPOLYGON:
85  UNREACHABLE();
86  default:
87  UNREACHABLE();
88  }
89  }
int8_t tinyintval
Definition: sqltypes.h:135
Definition: sqltypes.h:51
#define UNREACHABLE()
Definition: Logger.h:241
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:267
int32_t intval
Definition: sqltypes.h:137
float floatval
Definition: sqltypes.h:139
int64_t bigintval
Definition: sqltypes.h:138
int16_t smallintval
Definition: sqltypes.h:136
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:43
void updateMin(V &current_min, const T &value)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
Definition: sqltypes.h:47
void updateMax(V &current_max, const T &value)
double doubleval
Definition: sqltypes.h:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateStats() [2/2]

template<typename T >
void foreign_storage::ArrayMetadataStats::updateStats ( const SQLTypeInfo type_info,
const T &  min,
const T &  max 
)
inline

Definition at line 92 of file ArrayMetadataStats.h.

References Datum::bigintval, Datum::doubleval, Datum::floatval, SQLTypeInfo::get_compression(), SQLTypeInfo::get_type(), Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, max_, min_, Datum::smallintval, Datum::tinyintval, UNREACHABLE, updateMax(), and updateMin().

92  {
93  switch (type_info.get_type()) {
94  case kBOOLEAN: {
97  break;
98  }
99  case kTINYINT: {
100  updateMin(min_.tinyintval, min);
101  updateMax(max_.tinyintval, max);
102  break;
103  }
104  case kSMALLINT: {
105  updateMin(min_.smallintval, min);
106  updateMax(max_.smallintval, max);
107  break;
108  }
109  case kINT: {
110  updateMin(min_.intval, min);
111  updateMax(max_.intval, max);
112  break;
113  }
114  case kBIGINT:
115  case kNUMERIC:
116  case kDECIMAL: {
117  updateMin(min_.bigintval, min);
118  updateMax(max_.bigintval, max);
119  break;
120  }
121  case kTIME:
122  case kTIMESTAMP:
123  case kDATE: {
124  updateMin(min_.bigintval, min);
125  updateMax(max_.bigintval, max);
126  break;
127  }
128  case kFLOAT: {
129  updateMin(min_.floatval, min);
130  updateMax(max_.floatval, max);
131  break;
132  }
133  case kDOUBLE: {
134  updateMin(min_.doubleval, min);
135  updateMax(max_.doubleval, max);
136  break;
137  }
138  case kVARCHAR:
139  case kCHAR:
140  case kTEXT:
141  if (type_info.get_compression() == kENCODING_DICT) {
142  updateMin(min_.intval, min);
143  updateMax(max_.intval, max);
144  }
145  break;
146  case kPOINT:
147  case kLINESTRING:
148  case kPOLYGON:
149  case kMULTIPOLYGON:
150  UNREACHABLE();
151  default:
152  UNREACHABLE();
153  }
154  }
int8_t tinyintval
Definition: sqltypes.h:135
Definition: sqltypes.h:51
#define UNREACHABLE()
Definition: Logger.h:241
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:267
int32_t intval
Definition: sqltypes.h:137
float floatval
Definition: sqltypes.h:139
int64_t bigintval
Definition: sqltypes.h:138
int16_t smallintval
Definition: sqltypes.h:136
Definition: sqltypes.h:54
Definition: sqltypes.h:55
Definition: sqltypes.h:43
void updateMin(V &current_min, const T &value)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
Definition: sqltypes.h:47
void updateMax(V &current_max, const T &value)
double doubleval
Definition: sqltypes.h:140
+ Here is the call graph for this function:

Member Data Documentation

◆ is_max_initialized_

bool foreign_storage::ArrayMetadataStats::is_max_initialized_
private

Definition at line 276 of file ArrayMetadataStats.h.

Referenced by getMax(), and updateMax().

◆ is_min_initialized_

bool foreign_storage::ArrayMetadataStats::is_min_initialized_
private

Definition at line 275 of file ArrayMetadataStats.h.

Referenced by getMin(), and updateMin().

◆ max_

Datum foreign_storage::ArrayMetadataStats::max_
private

Definition at line 277 of file ArrayMetadataStats.h.

Referenced by getMax(), and updateStats().

◆ min_

Datum foreign_storage::ArrayMetadataStats::min_
private

Definition at line 277 of file ArrayMetadataStats.h.

Referenced by getMin(), and updateStats().


The documentation for this class was generated from the following file: