OmniSciDB  c07336695a
ArrayColumnDescriptor Class Reference
+ Inheritance diagram for ArrayColumnDescriptor:
+ Collaboration diagram for ArrayColumnDescriptor:

Public Member Functions

 ArrayColumnDescriptor (std::string def, const std::shared_ptr< TestColumnDescriptor > columnDesc, int fixed_len=0)
 
bool skip_test (std::string name) override
 
std::string get_column_definition () override
 
std::string make_column_value (int rows, std::string prefix, std::string suffix)
 
std::string get_column_value (int row) override
 
std::string get_update_column_value (int row) override
 
bool check_column_value (const int row, const TDatum *datum) override
 
 ArrayColumnDescriptor (std::string def, const std::shared_ptr< TestColumnDescriptor > columnDesc, int fixed_len=0)
 
bool skip_test (std::string name) override
 
std::string get_column_definition () override
 
std::string make_column_value (int rows, std::string prefix, std::string suffix)
 
std::string get_column_value (int row) override
 
std::string get_update_column_value (int row) override
 
bool check_column_value (const int row, const SQLTypeInfo &type, const TargetValue *value) override
 
bool check_column_value (const int row, const SQLTypeInfo &type, const ScalarTargetValue *scalarValue) override
 
- Public Member Functions inherited from TestColumnDescriptor
virtual ~TestColumnDescriptor ()=default
 
virtual ~TestColumnDescriptor ()=default
 

Public Attributes

std::string column_definition
 
const std::shared_ptr< TestColumnDescriptorelement_descriptor
 
int fixed_array_length
 

Detailed Description

Definition at line 339 of file CtasIntegrationTest.cpp.

Constructor & Destructor Documentation

◆ ArrayColumnDescriptor() [1/2]

ArrayColumnDescriptor::ArrayColumnDescriptor ( std::string  def,
const std::shared_ptr< TestColumnDescriptor columnDesc,
int  fixed_len = 0 
)
inline

Definition at line 345 of file CtasIntegrationTest.cpp.

348  : column_definition(def +
349  (fixed_len ? "[" + std::to_string(fixed_len) + "]" : "[]"))
350  , element_descriptor(columnDesc)
351  , fixed_array_length(fixed_len) {}
const std::shared_ptr< TestColumnDescriptor > element_descriptor
std::string to_string(char const *&&v)

◆ ArrayColumnDescriptor() [2/2]

ArrayColumnDescriptor::ArrayColumnDescriptor ( std::string  def,
const std::shared_ptr< TestColumnDescriptor columnDesc,
int  fixed_len = 0 
)
inline

Definition at line 317 of file CtasUpdateTest.cpp.

320  : column_definition(def +
321  (fixed_len ? "[" + std::to_string(fixed_len) + "]" : "[]"))
322  , element_descriptor(columnDesc)
323  , fixed_array_length(fixed_len) {}
const std::shared_ptr< TestColumnDescriptor > element_descriptor
std::string to_string(char const *&&v)

Member Function Documentation

◆ check_column_value() [1/3]

bool ArrayColumnDescriptor::check_column_value ( const int  row,
const SQLTypeInfo type,
const TargetValue value 
)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 363 of file CtasUpdateTest.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_elem_type().

365  {
366  auto arrayValue = boost::get<ArrayTargetValue>(value);
367 
368  if (!arrayValue) {
369  return false;
370  }
371  if (!arrayValue->is_initialized()) {
372  return true; // NULL array, nothing to check
373  }
374 
375  const SQLTypeInfo subtype = type.get_elem_type();
376 
377  int elementIndex = 1;
378 
379  if (fixed_array_length) {
380  elementIndex += row + 1;
381  }
382 
383  const auto& vec = arrayValue->get();
384  for (auto& scalarValue : vec) {
385  if (!element_descriptor->check_column_value(elementIndex, subtype, &scalarValue)) {
386  return false;
387  }
388 
389  elementIndex++;
390  }
391 
392  return true;
393  }
const std::shared_ptr< TestColumnDescriptor > element_descriptor
SQLTypeInfoCore get_elem_type() const
Definition: sqltypes.h:628
+ Here is the call graph for this function:

◆ check_column_value() [2/3]

bool ArrayColumnDescriptor::check_column_value ( const int  row,
const TDatum *  datum 
)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 391 of file CtasIntegrationTest.cpp.

391  {
392  if (row == 0 && datum->is_null) {
393  } else if (datum->is_null) {
394  return false;
395  }
396 
397  int elementIndex = 1;
398 
399  if (fixed_array_length) {
400  elementIndex += row;
401  }
402 
403  for (auto& dv : datum->val.arr_val) {
404  if (!element_descriptor->check_column_value(elementIndex, &dv)) {
405  return false;
406  }
407 
408  elementIndex++;
409  }
410 
411  return true;
412  }
const std::shared_ptr< TestColumnDescriptor > element_descriptor

◆ check_column_value() [3/3]

bool ArrayColumnDescriptor::check_column_value ( const int  row,
const SQLTypeInfo type,
const ScalarTargetValue scalarValue 
)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 395 of file CtasUpdateTest.cpp.

397  {
398  return false;
399  }

◆ get_column_definition() [1/2]

std::string ArrayColumnDescriptor::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 329 of file CtasUpdateTest.cpp.

329 { return column_definition; }

◆ get_column_definition() [2/2]

std::string ArrayColumnDescriptor::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 357 of file CtasIntegrationTest.cpp.

357 { return column_definition; }

◆ get_column_value() [1/2]

std::string ArrayColumnDescriptor::get_column_value ( int  row)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 355 of file CtasUpdateTest.cpp.

355  {
356  return make_column_value(row + 1, "{", "}");
357  }
std::string make_column_value(int rows, std::string prefix, std::string suffix)

◆ get_column_value() [2/2]

std::string ArrayColumnDescriptor::get_column_value ( int  row)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 383 of file CtasIntegrationTest.cpp.

383  {
384  return make_column_value(row, "{", "}");
385  }
std::string make_column_value(int rows, std::string prefix, std::string suffix)

◆ get_update_column_value() [1/2]

std::string ArrayColumnDescriptor::get_update_column_value ( int  row)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 359 of file CtasUpdateTest.cpp.

359  {
360  return make_column_value(row + 1, "ARRAY[", "]");
361  }
std::string make_column_value(int rows, std::string prefix, std::string suffix)

◆ get_update_column_value() [2/2]

std::string ArrayColumnDescriptor::get_update_column_value ( int  row)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 387 of file CtasIntegrationTest.cpp.

387  {
388  return make_column_value(row, "ARRAY[", "]");
389  }
std::string make_column_value(int rows, std::string prefix, std::string suffix)

◆ make_column_value() [1/2]

std::string ArrayColumnDescriptor::make_column_value ( int  rows,
std::string  prefix,
std::string  suffix 
)
inline

Definition at line 331 of file CtasUpdateTest.cpp.

References anonymous_namespace{RelAlgTranslatorGeo.cpp}::suffix().

331  {
332  std::string values = prefix;
333 
334  int i = 0;
335 
336  if (fixed_array_length) {
337  i = rows;
338  rows += fixed_array_length;
339  }
340 
341  bool firstElementWritten = false;
342 
343  for (; i < rows; i++) {
344  if (firstElementWritten) {
345  values += ", ";
346  }
347  values += element_descriptor->get_column_value(i + 1);
348  firstElementWritten = true;
349  }
350  values += suffix;
351 
352  return values;
353  }
const std::shared_ptr< TestColumnDescriptor > element_descriptor
+ Here is the call graph for this function:

◆ make_column_value() [2/2]

std::string ArrayColumnDescriptor::make_column_value ( int  rows,
std::string  prefix,
std::string  suffix 
)
inline

Definition at line 359 of file CtasIntegrationTest.cpp.

References anonymous_namespace{RelAlgTranslatorGeo.cpp}::suffix().

359  {
360  std::string values = prefix;
361 
362  int i = 0;
363 
364  if (fixed_array_length) {
365  i = rows;
366  rows += fixed_array_length;
367  }
368 
369  bool firstElementWritten = false;
370 
371  for (; i < rows; i++) {
372  if (firstElementWritten) {
373  values += ", ";
374  }
375  values += element_descriptor->get_column_value(i + 1);
376  firstElementWritten = true;
377  }
378  values += suffix;
379 
380  return values;
381  }
const std::shared_ptr< TestColumnDescriptor > element_descriptor
+ Here is the call graph for this function:

◆ skip_test() [1/2]

bool ArrayColumnDescriptor::skip_test ( std::string  name)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 325 of file CtasUpdateTest.cpp.

325  {
326  return element_descriptor->skip_test("Array." + name);
327  }
const std::shared_ptr< TestColumnDescriptor > element_descriptor

◆ skip_test() [2/2]

bool ArrayColumnDescriptor::skip_test ( std::string  name)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 353 of file CtasIntegrationTest.cpp.

353  {
354  return element_descriptor->skip_test("Array." + name);
355  }
const std::shared_ptr< TestColumnDescriptor > element_descriptor

Member Data Documentation

◆ column_definition

std::string ArrayColumnDescriptor::column_definition

Definition at line 341 of file CtasIntegrationTest.cpp.

◆ element_descriptor

const std::shared_ptr< TestColumnDescriptor > ArrayColumnDescriptor::element_descriptor

Definition at line 342 of file CtasIntegrationTest.cpp.

◆ fixed_array_length

int ArrayColumnDescriptor::fixed_array_length

Definition at line 343 of file CtasIntegrationTest.cpp.


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