OmniSciDB  ba1bac9284
 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:250

+ 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:214
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  return (array[0] == NULL_ARRAY_BOOLEAN);
173  }
174  case kINT: {
175  const int32_t* int_array = (int32_t*)array;
176  return (int_array[0] == NULL_ARRAY_INT);
177  }
178  case kSMALLINT: {
179  const int16_t* smallint_array = (int16_t*)array;
180  return (smallint_array[0] == NULL_ARRAY_SMALLINT);
181  }
182  case kTINYINT: {
183  const int8_t* tinyint_array = (int8_t*)array;
184  return (tinyint_array[0] == NULL_ARRAY_TINYINT);
185  }
186  case kBIGINT:
187  case kNUMERIC:
188  case kDECIMAL: {
189  const int64_t* bigint_array = (int64_t*)array;
190  return (bigint_array[0] == NULL_ARRAY_BIGINT);
191  }
192  case kFLOAT: {
193  const float* flt_array = (float*)array;
194  return (flt_array[0] == NULL_ARRAY_FLOAT);
195  }
196  case kDOUBLE: {
197  const double* dbl_array = (double*)array;
198  return (dbl_array[0] == NULL_ARRAY_DOUBLE);
199  }
200  case kTIME:
201  case kTIMESTAMP:
202  case kDATE: {
203  const int64_t* tm_array = reinterpret_cast<int64_t*>(array);
204  return (tm_array[0] == NULL_ARRAY_BIGINT);
205  }
206  case kCHAR:
207  case kVARCHAR:
208  case kTEXT: {
210  const int32_t* int_array = (int32_t*)array;
211  return (int_array[0] == NULL_ARRAY_INT);
212  }
213  default:
214  UNREACHABLE();
215  }
216  return false;
217  }
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:315
#define CHECK_EQ(x, y)
Definition: Logger.h:214
Definition: sqltypes.h:48
#define NULL_ARRAY_INT
#define NULL_ARRAY_SMALLINT
#define UNREACHABLE()
Definition: Logger.h:250
#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 245 of file FixedLengthArrayNoneEncoder.h.

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

Referenced by is_null().

245 { 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:206
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 219 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.

219  {
220  auto elem_type = buffer_->getSqlType().get_elem_type();
221  if (DatumEqual(elem_min, stats.min, elem_type) &&
222  DatumEqual(elem_max, stats.max, elem_type) && has_nulls == stats.has_nulls) {
223  return false;
224  }
225  elem_min = stats.min;
226  elem_max = stats.max;
227  has_nulls = stats.has_nulls;
228  return true;
229  }
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:713

+ 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 231 of file FixedLengthArrayNoneEncoder.h.

References has_nulls, and initialized.

void FixedLengthArrayNoneEncoder::update_elem_stats ( const ArrayDatum array)
inlineprivate

Definition at line 247 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().

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

bool FixedLengthArrayNoneEncoder::initialized

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