OmniSciDB  a667adc9c8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FixedLengthArrayNoneEncoder Class Reference

#include <FixedLengthArrayNoneEncoder.h>

+ Inheritance diagram for FixedLengthArrayNoneEncoder:
+ Collaboration diagram for FixedLengthArrayNoneEncoder:

Public Member Functions

 FixedLengthArrayNoneEncoder (AbstractBuffer *buffer, size_t as)
 
size_t getNumElemsForBytesInsertData (const std::vector< ArrayDatum > *srcData, const int start_idx, const size_t numAppendElems, const size_t byteLimit, const bool replicating=false)
 
std::shared_ptr< ChunkMetadataappendData (int8_t *&src_data, const size_t num_elems_to_append, const SQLTypeInfo &ti, const bool replicating=false, const int64_t offset=-1) override
 
std::shared_ptr< ChunkMetadataappendData (const std::vector< ArrayDatum > *srcData, const int start_idx, const size_t numAppendElems, const bool replicating=false)
 
void getMetadata (const std::shared_ptr< ChunkMetadata > &chunkMetadata) override
 
std::shared_ptr< ChunkMetadatagetMetadata (const SQLTypeInfo &ti) override
 
void updateStats (const int64_t, const bool) override
 
void updateStats (const double, const bool) override
 
void reduceStats (const Encoder &) override
 
void updateStats (const int8_t *const src_data, const size_t num_elements) override
 
void updateStats (const std::vector< std::string > *const src_data, const size_t start_idx, const size_t num_elements) override
 
void updateStats (const std::vector< ArrayDatum > *const src_data, const size_t start_idx, const size_t num_elements) override
 
void writeMetadata (FILE *f) override
 
void readMetadata (FILE *f) override
 
void copyMetadata (const Encoder *copyFromEncoder) override
 
void updateMetadata (int8_t *array)
 
bool resetChunkStats (const ChunkStats &stats) override
 : Reset chunk level stats (min, max, nulls) using new values from the argument. More...
 
void resetChunkStats () override
 
- Public Member Functions inherited from Encoder
 Encoder (Data_Namespace::AbstractBuffer *buffer)
 
virtual ~Encoder ()
 
virtual void updateStatsEncoded (const int8_t *const dst_data, const size_t num_elements)
 
size_t getNumElems () const
 
void setNumElems (const size_t num_elems)
 

Static Public Member Functions

static bool is_null (const SQLTypeInfo &type, int8_t *array)
 
- Static Public Member Functions inherited from Encoder
static EncoderCreate (Data_Namespace::AbstractBuffer *buffer, const SQLTypeInfo sqlType)
 

Public Attributes

Datum elem_min
 
Datum elem_max
 
bool has_nulls
 
bool initialized
 

Private Member Functions

bool is_null (int8_t *array)
 
void update_elem_stats (const ArrayDatum &array)
 

Private Attributes

std::mutex EncoderMutex_
 
size_t array_size
 

Additional Inherited Members

- Protected Attributes inherited from Encoder
size_t num_elems_
 
Data_Namespace::AbstractBufferbuffer_
 
DecimalOverflowValidator decimal_overflow_validator_
 
DateDaysOverflowValidator date_days_overflow_validator_
 

Detailed Description

Definition at line 41 of file FixedLengthArrayNoneEncoder.h.

Constructor & Destructor Documentation

FixedLengthArrayNoneEncoder::FixedLengthArrayNoneEncoder ( AbstractBuffer buffer,
size_t  as 
)
inline

Definition at line 43 of file FixedLengthArrayNoneEncoder.h.

44  : Encoder(buffer), has_nulls(false), initialized(false), array_size(as) {}
Encoder(Data_Namespace::AbstractBuffer *buffer)
Definition: Encoder.cpp:221

Member Function Documentation

std::shared_ptr<ChunkMetadata> FixedLengthArrayNoneEncoder::appendData ( int8_t *&  src_data,
const size_t  num_elems_to_append,
const SQLTypeInfo ti,
const bool  replicating = false,
const int64_t  offset = -1 
)
inlineoverridevirtual

Append data to the chunk buffer backing this encoder.

Parameters
src_dataSource data for the append
num_elems_to_appendNumber of elements to append
tiSQL Type Info for the column TODO(adb): used?
replicatingPass one value and fill the chunk with it
offsetWrite data starting at a given offset. Default is -1 which indicates an append, an offset of 0 rewrites the chunk up to num_elems_to_append.

Implements Encoder.

Definition at line 58 of file FixedLengthArrayNoneEncoder.h.

References UNREACHABLE.

Referenced by Chunk_NS::Chunk::appendData().

62  {
63  UNREACHABLE(); // should never be called for arrays
64  return nullptr;
65  }
#define UNREACHABLE()
Definition: Logger.h:241

+ Here is the caller graph for this function:

std::shared_ptr<ChunkMetadata> FixedLengthArrayNoneEncoder::appendData ( const std::vector< ArrayDatum > *  srcData,
const int  start_idx,
const size_t  numAppendElems,
const bool  replicating = false 
)
inline

Definition at line 67 of file FixedLengthArrayNoneEncoder.h.

References Data_Namespace::AbstractBuffer::append(), array_size, Encoder::buffer_, CHECK_EQ, getMetadata(), i, Data_Namespace::AbstractBuffer::isDirty(), Encoder::num_elems_, Data_Namespace::AbstractBuffer::reserve(), Data_Namespace::AbstractBuffer::setDirty(), and update_elem_stats().

70  {
71  size_t data_size = array_size * numAppendElems;
72  buffer_->reserve(data_size);
73 
74  for (size_t i = start_idx; i < start_idx + numAppendElems; i++) {
75  size_t len = (*srcData)[replicating ? 0 : i].length;
76  // Length of the appended array should be equal to the fixed length,
77  // all others should have been discarded, assert if something slips through
78  CHECK_EQ(len, array_size);
79  // NULL arrays have been filled with subtype's NULL sentinels,
80  // should be appended as regular data, same size
81  buffer_->append((*srcData)[replicating ? 0 : i].pointer, len);
82 
83  // keep Chunk statistics with array elements
84  update_elem_stats((*srcData)[replicating ? 0 : i]);
85  }
86  // make sure buffer_ is flushed even if no new data is appended to it
87  // (e.g. empty strings) because the metadata needs to be flushed.
88  if (!buffer_->isDirty()) {
89  buffer_->setDirty();
90  }
91 
92  num_elems_ += numAppendElems;
93  auto chunk_metadata = std::make_shared<ChunkMetadata>();
94  getMetadata(chunk_metadata);
95  return chunk_metadata;
96  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
size_t num_elems_
Definition: Encoder.h:237
void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata) override
Data_Namespace::AbstractBuffer * buffer_
Definition: Encoder.h:239
virtual void append(int8_t *src, const size_t num_bytes, const MemoryLevel src_buffer_type=CPU_LEVEL, const int device_id=-1)=0
void update_elem_stats(const ArrayDatum &array)
virtual void reserve(size_t num_bytes)=0

+ Here is the call graph for this function:

void FixedLengthArrayNoneEncoder::copyMetadata ( const Encoder copyFromEncoder)
inlineoverridevirtual

Implements Encoder.

Definition at line 152 of file FixedLengthArrayNoneEncoder.h.

References elem_max, elem_min, Encoder::getNumElems(), has_nulls, initialized, and Encoder::num_elems_.

152  {
153  num_elems_ = copyFromEncoder->getNumElems();
154  auto array_encoder =
155  dynamic_cast<const FixedLengthArrayNoneEncoder*>(copyFromEncoder);
156  elem_min = array_encoder->elem_min;
157  elem_max = array_encoder->elem_max;
158  has_nulls = array_encoder->has_nulls;
159  initialized = array_encoder->initialized;
160  }
size_t num_elems_
Definition: Encoder.h:237
size_t getNumElems() const
Definition: Encoder.h:233

+ Here is the call graph for this function:

void FixedLengthArrayNoneEncoder::getMetadata ( const std::shared_ptr< ChunkMetadata > &  chunkMetadata)
inlineoverridevirtual

Reimplemented from Encoder.

Definition at line 98 of file FixedLengthArrayNoneEncoder.h.

References elem_max, elem_min, Encoder::getMetadata(), and has_nulls.

Referenced by appendData().

98  {
99  Encoder::getMetadata(chunkMetadata); // call on parent class
100  chunkMetadata->fillChunkStats(elem_min, elem_max, has_nulls);
101  }
virtual void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata)
Definition: Encoder.cpp:227

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<ChunkMetadata> FixedLengthArrayNoneEncoder::getMetadata ( const SQLTypeInfo ti)
inlineoverridevirtual

Implements Encoder.

Definition at line 104 of file FixedLengthArrayNoneEncoder.h.

References elem_max, elem_min, and has_nulls.

104  {
105  auto chunk_metadata = std::make_shared<ChunkMetadata>(
106  ti, 0, 0, ChunkStats{elem_min, elem_max, has_nulls});
107  return chunk_metadata;
108  }
size_t FixedLengthArrayNoneEncoder::getNumElemsForBytesInsertData ( const std::vector< ArrayDatum > *  srcData,
const int  start_idx,
const size_t  numAppendElems,
const size_t  byteLimit,
const bool  replicating = false 
)
inline

Definition at line 46 of file FixedLengthArrayNoneEncoder.h.

References array_size.

Referenced by Chunk_NS::Chunk::getNumElemsForBytesInsertData().

50  {
51  size_t dataSize = numAppendElems * array_size;
52  if (dataSize > byteLimit) {
53  dataSize = byteLimit;
54  }
55  return dataSize / array_size;
56  }

+ Here is the caller graph for this function:

static bool FixedLengthArrayNoneEncoder::is_null ( const SQLTypeInfo type,
int8_t *  array 
)
inlinestatic

Definition at line 166 of file FixedLengthArrayNoneEncoder.h.

References CHECK_EQ, SQLTypeInfo::get_compression(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_subtype(), kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kNUMERIC, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, NULL_ARRAY_BIGINT, NULL_ARRAY_BOOLEAN, NULL_ARRAY_DOUBLE, NULL_ARRAY_FLOAT, NULL_ARRAY_INT, NULL_ARRAY_SMALLINT, NULL_ARRAY_TINYINT, and UNREACHABLE.

Referenced by Fragmenter_Namespace::FixedLenArrayChunkConverter::convertToColumnarFormat(), and updateMetadata().

166  {
167  if (type.get_notnull()) {
168  return false;
169  }
170  switch (type.get_subtype()) {
171  case kBOOLEAN: {
172  const bool* bool_array = (bool*)array;
173  return ((int8_t)bool_array[0] == NULL_ARRAY_BOOLEAN);
174  }
175  case kINT: {
176  const int32_t* int_array = (int32_t*)array;
177  return (int_array[0] == NULL_ARRAY_INT);
178  }
179  case kSMALLINT: {
180  const int16_t* smallint_array = (int16_t*)array;
181  return (smallint_array[0] == NULL_ARRAY_SMALLINT);
182  }
183  case kTINYINT: {
184  const int8_t* tinyint_array = (int8_t*)array;
185  return (tinyint_array[0] == NULL_ARRAY_TINYINT);
186  }
187  case kBIGINT:
188  case kNUMERIC:
189  case kDECIMAL: {
190  const int64_t* bigint_array = (int64_t*)array;
191  return (bigint_array[0] == NULL_ARRAY_BIGINT);
192  }
193  case kFLOAT: {
194  const float* flt_array = (float*)array;
195  return (flt_array[0] == NULL_ARRAY_FLOAT);
196  }
197  case kDOUBLE: {
198  const double* dbl_array = (double*)array;
199  return (dbl_array[0] == NULL_ARRAY_DOUBLE);
200  }
201  case kTIME:
202  case kTIMESTAMP:
203  case kDATE: {
204  const int64_t* tm_array = reinterpret_cast<int64_t*>(array);
205  return (tm_array[0] == NULL_ARRAY_BIGINT);
206  }
207  case kCHAR:
208  case kVARCHAR:
209  case kTEXT: {
211  const int32_t* int_array = (int32_t*)array;
212  return (int_array[0] == NULL_ARRAY_INT);
213  }
214  default:
215  UNREACHABLE();
216  }
217  return false;
218  }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:315
#define CHECK_EQ(x, y)
Definition: Logger.h:205
Definition: sqltypes.h:48
#define NULL_ARRAY_INT
#define NULL_ARRAY_SMALLINT
#define UNREACHABLE()
Definition: Logger.h:241
#define NULL_ARRAY_TINYINT
#define NULL_ARRAY_FLOAT
Definition: sqltypes.h:51
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:322
Definition: sqltypes.h:40
#define NULL_ARRAY_DOUBLE
#define NULL_ARRAY_BIGINT
Definition: sqltypes.h:44
#define NULL_ARRAY_BOOLEAN
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:321

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool FixedLengthArrayNoneEncoder::is_null ( int8_t *  array)
inlineprivate

Definition at line 246 of file FixedLengthArrayNoneEncoder.h.

References Encoder::buffer_, Data_Namespace::AbstractBuffer::getSqlType(), and is_null().

Referenced by is_null().

246 { return is_null(buffer_->getSqlType(), array); }
Data_Namespace::AbstractBuffer * buffer_
Definition: Encoder.h:239
SQLTypeInfo getSqlType() const
static bool is_null(const SQLTypeInfo &type, int8_t *array)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FixedLengthArrayNoneEncoder::readMetadata ( FILE *  f)
inlineoverridevirtual

Implements Encoder.

Definition at line 143 of file FixedLengthArrayNoneEncoder.h.

References elem_max, elem_min, has_nulls, initialized, and Encoder::num_elems_.

143  {
144  // assumes pointer is already in right place
145  fread((int8_t*)&num_elems_, sizeof(size_t), 1, f);
146  fread((int8_t*)&elem_min, sizeof(Datum), 1, f);
147  fread((int8_t*)&elem_max, sizeof(Datum), 1, f);
148  fread((int8_t*)&has_nulls, sizeof(bool), 1, f);
149  fread((int8_t*)&initialized, sizeof(bool), 1, f);
150  }
size_t num_elems_
Definition: Encoder.h:237
char * f
void FixedLengthArrayNoneEncoder::reduceStats ( const Encoder )
inlineoverridevirtual

Implements Encoder.

Definition at line 114 of file FixedLengthArrayNoneEncoder.h.

References CHECK.

114 { CHECK(false); }
#define CHECK(condition)
Definition: Logger.h:197
bool FixedLengthArrayNoneEncoder::resetChunkStats ( const ChunkStats )
inlineoverridevirtual

: Reset chunk level stats (min, max, nulls) using new values from the argument.

Returns
: True if an update occurred and the chunk needs to be flushed. False otherwise. Default false if metadata update is unsupported. Only reset chunk stats if the incoming stats differ from the current stats.

Reimplemented from Encoder.

Definition at line 220 of file FixedLengthArrayNoneEncoder.h.

References Encoder::buffer_, DatumEqual(), elem_max, elem_min, SQLTypeInfo::get_elem_type(), Data_Namespace::AbstractBuffer::getSqlType(), ChunkStats::has_nulls, has_nulls, ChunkStats::max, and ChunkStats::min.

220  {
221  auto elem_type = buffer_->getSqlType().get_elem_type();
222  if (DatumEqual(elem_min, stats.min, elem_type) &&
223  DatumEqual(elem_max, stats.max, elem_type) && has_nulls == stats.has_nulls) {
224  return false;
225  }
226  elem_min = stats.min;
227  elem_max = stats.max;
228  has_nulls = stats.has_nulls;
229  return true;
230  }
Data_Namespace::AbstractBuffer * buffer_
Definition: Encoder.h:239
bool DatumEqual(const Datum a, const Datum b, const SQLTypeInfo &ti)
Definition: Datum.cpp:306
SQLTypeInfo getSqlType() const
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:712

+ Here is the call graph for this function:

void FixedLengthArrayNoneEncoder::resetChunkStats ( )
inlineoverridevirtual

Resets chunk metadata stats to their default values.

Implements Encoder.

Definition at line 232 of file FixedLengthArrayNoneEncoder.h.

References has_nulls, and initialized.

void FixedLengthArrayNoneEncoder::update_elem_stats ( const ArrayDatum array)
inlineprivate

Definition at line 248 of file FixedLengthArrayNoneEncoder.h.

References Datum::bigintval, Datum::boolval, Encoder::buffer_, CHECK_EQ, Encoder::decimal_overflow_validator_, Datum::doubleval, elem_max, elem_min, Datum::floatval, SQLTypeInfo::get_compression(), SQLTypeInfo::get_subtype(), Data_Namespace::AbstractBuffer::getSqlType(), has_nulls, i, initialized, Datum::intval, kBIGINT, kBOOLEAN, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kFLOAT, kINT, kNUMERIC, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, NULL_BIGINT, NULL_BOOLEAN, NULL_DOUBLE, NULL_FLOAT, NULL_INT, NULL_SMALLINT, NULL_TINYINT, Datum::smallintval, Datum::tinyintval, UNREACHABLE, and DecimalOverflowValidator::validate().

Referenced by appendData(), updateMetadata(), and updateStats().

248  {
249  if (array.is_null) {
250  has_nulls = true;
251  }
252  switch (buffer_->getSqlType().get_subtype()) {
253  case kBOOLEAN: {
254  if (!initialized) {
255  elem_min.boolval = true;
256  elem_max.boolval = false;
257  }
258  if (array.is_null) {
259  break;
260  }
261  const bool* bool_array = (bool*)array.pointer;
262  for (size_t i = 0; i < array.length / sizeof(bool); i++) {
263  if ((int8_t)bool_array[i] == NULL_BOOLEAN) {
264  has_nulls = true;
265  } else if (initialized) {
266  elem_min.boolval = std::min(elem_min.boolval, bool_array[i]);
267  elem_max.boolval = std::max(elem_max.boolval, bool_array[i]);
268  } else {
269  elem_min.boolval = bool_array[i];
270  elem_max.boolval = bool_array[i];
271  initialized = true;
272  }
273  }
274  break;
275  }
276  case kINT: {
277  if (!initialized) {
278  elem_min.intval = 1;
279  elem_max.intval = 0;
280  }
281  if (array.is_null) {
282  break;
283  }
284  const int32_t* int_array = (int32_t*)array.pointer;
285  for (size_t i = 0; i < array.length / sizeof(int32_t); i++) {
286  if (int_array[i] == NULL_INT) {
287  has_nulls = true;
288  } else if (initialized) {
289  elem_min.intval = std::min(elem_min.intval, int_array[i]);
290  elem_max.intval = std::max(elem_max.intval, int_array[i]);
291  } else {
292  elem_min.intval = int_array[i];
293  elem_max.intval = int_array[i];
294  initialized = true;
295  }
296  }
297  break;
298  }
299  case kSMALLINT: {
300  if (!initialized) {
301  elem_min.smallintval = 1;
302  elem_max.smallintval = 0;
303  }
304  if (array.is_null) {
305  break;
306  }
307  const int16_t* smallint_array = (int16_t*)array.pointer;
308  for (size_t i = 0; i < array.length / sizeof(int16_t); i++) {
309  if (smallint_array[i] == NULL_SMALLINT) {
310  has_nulls = true;
311  } else if (initialized) {
312  elem_min.smallintval = std::min(elem_min.smallintval, smallint_array[i]);
313  elem_max.smallintval = std::max(elem_max.smallintval, smallint_array[i]);
314  } else {
315  elem_min.smallintval = smallint_array[i];
316  elem_max.smallintval = smallint_array[i];
317  initialized = true;
318  }
319  }
320  break;
321  }
322  case kTINYINT: {
323  if (!initialized) {
324  elem_min.tinyintval = 1;
325  elem_max.tinyintval = 0;
326  }
327  if (array.is_null) {
328  break;
329  }
330  const int8_t* tinyint_array = (int8_t*)array.pointer;
331  for (size_t i = 0; i < array.length / sizeof(int8_t); i++) {
332  if (tinyint_array[i] == NULL_TINYINT) {
333  has_nulls = true;
334  } else if (initialized) {
335  elem_min.tinyintval = std::min(elem_min.tinyintval, tinyint_array[i]);
336  elem_max.tinyintval = std::max(elem_max.tinyintval, tinyint_array[i]);
337  } else {
338  elem_min.tinyintval = tinyint_array[i];
339  elem_max.tinyintval = tinyint_array[i];
340  initialized = true;
341  }
342  }
343  break;
344  }
345  case kBIGINT:
346  case kNUMERIC:
347  case kDECIMAL: {
348  if (!initialized) {
349  elem_min.bigintval = 1;
350  elem_max.bigintval = 0;
351  }
352  if (array.is_null) {
353  break;
354  }
355  const int64_t* bigint_array = (int64_t*)array.pointer;
356  for (size_t i = 0; i < array.length / sizeof(int64_t); i++) {
357  if (bigint_array[i] == NULL_BIGINT) {
358  has_nulls = true;
359  } else if (initialized) {
360  decimal_overflow_validator_.validate(bigint_array[i]);
361  elem_min.bigintval = std::min(elem_min.bigintval, bigint_array[i]);
362  elem_max.bigintval = std::max(elem_max.bigintval, bigint_array[i]);
363  } else {
364  decimal_overflow_validator_.validate(bigint_array[i]);
365  elem_min.bigintval = bigint_array[i];
366  elem_max.bigintval = bigint_array[i];
367  initialized = true;
368  }
369  }
370  break;
371  }
372  case kFLOAT: {
373  if (!initialized) {
374  elem_min.floatval = 1.0;
375  elem_max.floatval = 0.0;
376  }
377  if (array.is_null) {
378  break;
379  }
380  const float* flt_array = (float*)array.pointer;
381  for (size_t i = 0; i < array.length / sizeof(float); i++) {
382  if (flt_array[i] == NULL_FLOAT) {
383  has_nulls = true;
384  } else if (initialized) {
385  elem_min.floatval = std::min(elem_min.floatval, flt_array[i]);
386  elem_max.floatval = std::max(elem_max.floatval, flt_array[i]);
387  } else {
388  elem_min.floatval = flt_array[i];
389  elem_max.floatval = flt_array[i];
390  initialized = true;
391  }
392  }
393  break;
394  }
395  case kDOUBLE: {
396  if (!initialized) {
397  elem_min.doubleval = 1.0;
398  elem_max.doubleval = 0.0;
399  }
400  if (array.is_null) {
401  break;
402  }
403  const double* dbl_array = (double*)array.pointer;
404  for (size_t i = 0; i < array.length / sizeof(double); i++) {
405  if (dbl_array[i] == NULL_DOUBLE) {
406  has_nulls = true;
407  } else if (initialized) {
408  elem_min.doubleval = std::min(elem_min.doubleval, dbl_array[i]);
409  elem_max.doubleval = std::max(elem_max.doubleval, dbl_array[i]);
410  } else {
411  elem_min.doubleval = dbl_array[i];
412  elem_max.doubleval = dbl_array[i];
413  initialized = true;
414  }
415  }
416  break;
417  }
418  case kTIME:
419  case kTIMESTAMP:
420  case kDATE: {
421  if (!initialized) {
422  elem_min.bigintval = 1;
423  elem_max.bigintval = 0;
424  }
425  if (array.is_null) {
426  break;
427  }
428  const int64_t* tm_array = reinterpret_cast<int64_t*>(array.pointer);
429  for (size_t i = 0; i < array.length / sizeof(int64_t); i++) {
430  if (tm_array[i] == NULL_BIGINT) {
431  has_nulls = true;
432  } else if (initialized) {
433  elem_min.bigintval = std::min(elem_min.bigintval, tm_array[i]);
434  elem_max.bigintval = std::max(elem_max.bigintval, tm_array[i]);
435  } else {
436  elem_min.bigintval = tm_array[i];
437  elem_max.bigintval = tm_array[i];
438  initialized = true;
439  }
440  }
441  break;
442  }
443  case kCHAR:
444  case kVARCHAR:
445  case kTEXT: {
447  if (!initialized) {
448  elem_min.intval = 1;
449  elem_max.intval = 0;
450  }
451  if (array.is_null) {
452  break;
453  }
454  const int32_t* int_array = (int32_t*)array.pointer;
455  for (size_t i = 0; i < array.length / sizeof(int32_t); i++) {
456  if (int_array[i] == NULL_INT) {
457  has_nulls = true;
458  } else if (initialized) {
459  elem_min.intval = std::min(elem_min.intval, int_array[i]);
460  elem_max.intval = std::max(elem_max.intval, int_array[i]);
461  } else {
462  elem_min.intval = int_array[i];
463  elem_max.intval = int_array[i];
464  initialized = true;
465  }
466  }
467  break;
468  }
469  default:
470  UNREACHABLE();
471  }
472  };
int8_t tinyintval
Definition: sqltypes.h:206
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:315
#define CHECK_EQ(x, y)
Definition: Logger.h:205
#define NULL_DOUBLE
Definition: sqltypes.h:48
#define NULL_FLOAT
DecimalOverflowValidator decimal_overflow_validator_
Definition: Encoder.h:241
#define NULL_BIGINT
bool boolval
Definition: sqltypes.h:205
#define UNREACHABLE()
Definition: Logger.h:241
int32_t intval
Definition: sqltypes.h:208
#define NULL_INT
float floatval
Definition: sqltypes.h:210
Data_Namespace::AbstractBuffer * buffer_
Definition: Encoder.h:239
int64_t bigintval
Definition: sqltypes.h:209
int16_t smallintval
Definition: sqltypes.h:207
#define NULL_BOOLEAN
void validate(T value)
Definition: Encoder.h:54
Definition: sqltypes.h:51
Definition: sqltypes.h:52
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:322
Definition: sqltypes.h:40
SQLTypeInfo getSqlType() const
#define NULL_TINYINT
#define NULL_SMALLINT
Definition: sqltypes.h:44
double doubleval
Definition: sqltypes.h:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FixedLengthArrayNoneEncoder::updateMetadata ( int8_t *  array)
inline

Definition at line 162 of file FixedLengthArrayNoneEncoder.h.

References array_size, is_null(), and update_elem_stats().

162  {
164  }
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:202
void update_elem_stats(const ArrayDatum &array)
static bool is_null(const SQLTypeInfo &type, int8_t *array)

+ Here is the call graph for this function:

void FixedLengthArrayNoneEncoder::updateStats ( const int64_t  ,
const bool   
)
inlineoverridevirtual

Implements Encoder.

Definition at line 110 of file FixedLengthArrayNoneEncoder.h.

References CHECK.

110 { CHECK(false); }
#define CHECK(condition)
Definition: Logger.h:197
void FixedLengthArrayNoneEncoder::updateStats ( const double  ,
const bool   
)
inlineoverridevirtual

Implements Encoder.

Definition at line 112 of file FixedLengthArrayNoneEncoder.h.

References CHECK.

112 { CHECK(false); }
#define CHECK(condition)
Definition: Logger.h:197
void FixedLengthArrayNoneEncoder::updateStats ( const int8_t *const  src_data,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for data without appending.

Parameters
src_data- the data with which to update statistics
num_elements- the number of elements to scan in the data

Implements Encoder.

Definition at line 116 of file FixedLengthArrayNoneEncoder.h.

References UNREACHABLE.

116  {
117  UNREACHABLE();
118  }
#define UNREACHABLE()
Definition: Logger.h:241
void FixedLengthArrayNoneEncoder::updateStats ( const std::vector< std::string > *const  src_data,
const size_t  start_idx,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for string data without appending.

Parameters
src_data- the string data with which to update statistics
start_idx- the offset into src_data to start the update
num_elements- the number of elements to scan in the string data

Implements Encoder.

Definition at line 120 of file FixedLengthArrayNoneEncoder.h.

References UNREACHABLE.

122  {
123  UNREACHABLE();
124  }
#define UNREACHABLE()
Definition: Logger.h:241
void FixedLengthArrayNoneEncoder::updateStats ( const std::vector< ArrayDatum > *const  src_data,
const size_t  start_idx,
const size_t  num_elements 
)
inlineoverridevirtual

Update statistics for array data without appending.

Parameters
src_data- the array data with which to update statistics
start_idx- the offset into src_data to start the update
num_elements- the number of elements to scan in the array data

Implements Encoder.

Definition at line 126 of file FixedLengthArrayNoneEncoder.h.

References update_elem_stats().

128  {
129  for (size_t n = start_idx; n < start_idx + num_elements; n++) {
130  update_elem_stats((*src_data)[n]);
131  }
132  }
void update_elem_stats(const ArrayDatum &array)

+ Here is the call graph for this function:

void FixedLengthArrayNoneEncoder::writeMetadata ( FILE *  f)
inlineoverridevirtual

Implements Encoder.

Definition at line 134 of file FixedLengthArrayNoneEncoder.h.

References elem_max, elem_min, has_nulls, initialized, and Encoder::num_elems_.

134  {
135  // assumes pointer is already in right place
136  fwrite((int8_t*)&num_elems_, sizeof(size_t), 1, f);
137  fwrite((int8_t*)&elem_min, sizeof(Datum), 1, f);
138  fwrite((int8_t*)&elem_max, sizeof(Datum), 1, f);
139  fwrite((int8_t*)&has_nulls, sizeof(bool), 1, f);
140  fwrite((int8_t*)&initialized, sizeof(bool), 1, f);
141  }
size_t num_elems_
Definition: Encoder.h:237
char * f

Member Data Documentation

size_t FixedLengthArrayNoneEncoder::array_size
private
Datum FixedLengthArrayNoneEncoder::elem_max
Datum FixedLengthArrayNoneEncoder::elem_min
std::mutex FixedLengthArrayNoneEncoder::EncoderMutex_
private

Definition at line 243 of file FixedLengthArrayNoneEncoder.h.

bool FixedLengthArrayNoneEncoder::initialized

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